参考 Sending Emails Through Outlook using C# and VB.NET http://www.c-sharpcorner.com/Internet/SendingEmailsThroughOutlookCB.asp注意,一般ASP.NET页面是在ASPNET账号下执行的,该账号也许无法运行如果你要在客户端实现,或者用你原来的方法,但写在客户端的VBSCRIPT里,或用 <a href="mailto:[email protected]?Subject=Subject goes here&Body=Body text">send mail</a>当然你可以用客户端脚本改变mailto的内容还有,以后尽量不要这样指名道姓地问问题,会招人反感的
>>>>谢谢saucer.你说的这篇文章我已经看过了,也尝试过了,可是行不通。 use impersonation if your client's ActiveX security settings are low, try<script language="VBScript"> sub SendMail() set objApp=CreateObject("Outlook.Application") set objMail=olApp.CreateItem(olMailItem) '.... end sub </script> <input type="button" value="send mail" onclick="vbscript:SendMail">
Sending Emails Through Outlook using C# and VB.NET
http://www.c-sharpcorner.com/Internet/SendingEmailsThroughOutlookCB.asp注意,一般ASP.NET页面是在ASPNET账号下执行的,该账号也许无法运行如果你要在客户端实现,或者用你原来的方法,但写在客户端的VBSCRIPT里,或用
<a href="mailto:[email protected]?Subject=Subject goes here&Body=Body text">send mail</a>当然你可以用客户端脚本改变mailto的内容还有,以后尽量不要这样指名道姓地问问题,会招人反感的
<a href="mailto:[email protected]?subject=这是主题&body=这是邮件的内容">contact me</a>
同时呢,你告诉我的另外一种办法mailto,虽然可以调用得了Outlook,可是不能自动的将mail发出去,而且作为客户还可以对内容进行修改,这是我不想看到的。
也要谢谢webdiyer。
最后向saucer,向其他高手道歉~~~~~
希望各位不要见怪。因为我太想知道答案了,可是现在还是不能解决啊~~~~~~~~~
use impersonation
if your client's ActiveX security settings are low, try<script language="VBScript">
sub SendMail()
set objApp=CreateObject("Outlook.Application")
set objMail=olApp.CreateItem(olMailItem)
'....
end sub
</script>
<input type="button" value="send mail" onclick="vbscript:SendMail">
http://www.microsoft.com/china/msdn/library/dnofftalk/html/office10032002.asp
http://www.microsoft.com/china/msdn/library/dndotnetout2k2/html/odc_oldevsol.asp
<html>
<head>
</head>
<script language=vbscript >
sub Send
Dim myOlApp
Set myOlApp = CreateObject("Outlook.Application")Dim objMail
set objMail=myOlApp.CreateItem(olMailItem)
objMail.To = "[email protected]"
objMail.Subject = "sample email"
objMail.Body = "Hi,\nI'm your sample email."
objMail.SaveSet myOlApp = Nothing
end sub </script><script language="C#" runat="server">
public void button_Click(Object sender,EventArgs e)
{
数据库更新等操作;
Response.Write("<script language=vbscript>Send");
Response.Write("</"+"script>");
}
</script>
<body>
<form runat=server>
<asp:button text="Send" OnClick="button_Click" runat="server"/>
</form>
</body>
</html>以上这样写仍有问题。提示:Send类型不匹配~
一种就是你说的在asp.NET中用Web.Maim这个空间的类去发
还有一种就是你要在客户端发送
我想你可以在ASP中用的为什么不能在asp.net有呢?
你可以引入outlook的组件啊
这样不就是可以了
实现的方式有许多种你也可以自已实现一个类来做
我觉得asp.net的Main中的类是很好的
你可以用来试试微软开发出来是有它的道理的你说对吧
objMail.Send("from","to" ,"subject","body","importance");
//如 objMail.Send("*@hnair.com","*@hotmail.com","Asp.Net","Ok",2);
objMail=null;