12,162
社区成员
发帖
与我相关
我的任务
分享
[WebMethod]
///发送Email
///参数:fromaddress-发件人 toaddress-收件人 标题-title content-内容
public bool SendEmail(string fromaddress, string toaddress, string title, string content)
{
try
{
MailMessage newmail = new MailMessage();
newmail.From = new MailAddress(fromaddress);
newmail.To.Add(new MailAddress(toaddress));//因为可以抄送 对应多人
newmail.Subject = title;
newmail.Body = content;
newmail.IsBodyHtml = false;
//use SmtpClint send Email
SmtpClient getclint = new SmtpClient();
getclint.EnableSsl = true;
getclint.Send(newmail);
return true;
}
catch (Exception se)
{
return false;
}
return false;
}
XML
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" port="587"
userName="terrylee@gmail.com" password=""/>
</smtp>
</mailSettings>
</system.net>