/**//// <summary> foreach (MailAddress m in email) mm.Subject = subject;
\n
/// 发送系统邮件
/// </summary>
/// <param name=”email”>收件人</param>
/// <param name=”body”>内容</param>
/// <param name=”subject”>标题</param>
/// <param name=”cc”>抄送人</param>
/// <returns></returns>
public static bool SendM(MailAddressCollection email, string body, string subject, MailAddressCollection cc)
{
//try
//{
if (email != null && email.Count > 0)
{
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
//mm.From = “webservice@*****.***”;
mm.IsBodyHtml = true;
mm.Body = body;
\n
mm.To.Add(m);
if (cc != null && cc.Count > 0)
{
foreach (MailAddress s in cc)
mm.CC.Add(s);
}
mm.Priority = System.Net.Mail.MailPriority.High;
\n
System.Net.Mail.SmtpClient sc = new SmtpClient();
//sc.Host = “mail.pypo.net”;
sc.Send(mm);
return true;
}
else
return false;
//}
//catch
//{
// return false;
//}
}
在webconfig设置
\n
<system.net>
<mailSettings>
<smtp from=”****@*****.***” >
<network host=”mailhost” port=”25″ userName=”webservice” password=”*******”/>
</smtp>
</mailSettings>
</system.net>另,要注意SMTP的设置,SMTP属性->访问->中继权限,最好选择“仅以下列表除外”(也可以选择“仅以下列表” 自己添加允许的列表)
来源:http://blog.csdn.net/eduxh