用c#和jmail开发Asp.net的mail发送

Asp.net 中的 mail 的发送

现在的邮件发送大多数需要验证,我写这篇文章是希望对大家开发项目有所帮助,也希望大家能给我提点意见。

把 jmail 引用到工程中,加入 jmail 的命名空间,在这里我将引用 jmail 包的 MessageClass类。

Logging属性: 是否使用日志

Silent属性: 如果设置为 true,JMail 不会抛出例外错误 . JMail. Send ( () 会根据操作结果返回 true 或 false

MailServerUserName属性:发信人的用户名,如: [email protected] ;

MailServerPassWord属性:发信人的密码

From 属性:发信人

Subject 属性: 主题

AddAttachment()方法:附加文件

Body属性:邮件正文。

下面是一个完整的例子:

public bool sendMail()

{

MessageClass email = new MessageClass();

email.Logging = true ;

email.Silent = true ;

email.MailServerUserName = " [email protected] ";

email.MailServerPassWord = "124";

email.From = " [email protected] ";

email.Subject = "jmail";

email.AddAttachment("c:\\test.xml", true ,"");

email.Body = "test jmail send mail";

email.AddRecipient(" [email protected] ", "abc", null );

return email.Send("mail.163.com", false )

}

作者:潘敏

e-mail:[email protected]

msn:[email protected]

Published At
Categories with Web编程
Tagged with
comments powered by Disqus