.net里使用jmail

参考网上的一篇文章:http://www.webdn.com/web_file/program/asp.net/0602080139/

内容如下:

ASP.Net环境下使用Jmail组件发送邮件

 

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>

【摘 要】不同于在Asp中使用Jmail,直接使用 Server.CreateObject就可以了。在.Net环境中,需要进行设置。

 

  配置环境:.Net Framework 1.1,Imai8.02,w3Jmail4.3

实现过程:

不同于在Asp中使用Jmail,直接使用 Server.CreateObject("Jmail.Message")就可以了。在.Net环境中,需要进行设置。

1.安装jmail4.3

2.找到jmail.dll(Program Files/Dimac/w3JMail4下)

3.执行Program Files/Microsoft Visual Studio .NET/FrameworkSDK/Bin/ildasm.exe(可使用Visual Studio .Net 2003 命令提示),

格式如下:tlbimp c:/Program Files/Dimac/w3JMail4/jmail.dll /out:myJmail.dll /namespace:myJmail

生成myJmail.dll后,copy到web的根目录的bin目录。在ASP.Net页面中,用这个方法引用:

Jmail.aspx

<%@ Page Language="C#" ContentType="text/html"%>

<%@ Import Namespace="myJmail" %>

<script runat="server">

protected void Page_Load(Object Src, EventArgs E)

{

 

Message jmail=new Message();

jmail.From="sss";

jmail.AddRecipient("lsg@ckocoo.com",null,null);

jmail.MailServerUserName="brookes";

jmail.MailServerPassWord="walkor";

jmail.Subject="jmail c#";

jmail.Send("mail.lsg.com",false);

</script>

 

Tlbimp:

Microsoft .Net Framework Type Library to Assembly Converter

 

按上面的方法添加引用后,还是不能发送。老出错:

The message was undeliverable. All servers failed to receive the message

不知道什么原因.邮件服务器,用户名和密码放在本机的outlook express的设置里可以发信收信。页面上就出错。

加了Response.ContentType="text/html"; 还是这个错误。本机的smtp服务关了没用。防火墙关了,突然不出错了,刷了五下也没错。打开本机的outlook express,收到五封邮件。

我用的是VirusScan Enterprise杀毒软件,后来在控件台-访问保护-端口阻挡-要阻挡的端口-[禁止大量发送邮件的蠕虫病毒发送邮件-双击-已排除进程-添加aspnet_wp.exe(我是这个进程).就可以发邮件了。

后来没有用JMAIL,用.NET类库了,网上有现成的资料,如下:

MailMessage mail = new MailMessage();

mail.To = "xxxxxx@hotmail.com";
mail.Bcc = "xxxxxxx@gmail.com";
mail.From = "xxxxx@abc.com";
mail.BodyFormat = MailFormat.Text;
mail.Subject = "Subject of this Email " + System.DateTime.Now.ToString();
mail.Body = "Body of this message.";


SmtpMail.SmtpServer="www.abc.com";

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "loginname");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Password");

SmtpMail.Send(mail);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚上吃酱牛肉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值