Joke Collection Website - Public benefit messages - 如果邮箱需要安全套接层加密访问 请问如何用c#发邮件

如果邮箱需要安全套接层加密访问 请问如何用c#发邮件

这个是我自己做的一个即时通信软件发邮件代码,注:ssl加密要到邮箱里发短信来获取密码(不是你的即时通信软件密码)

代码如下:

private bool SendMail(Form2。History hsSendInfo,string warning = null)

{

尝试

{

string HostName = System。net . DNS . get hostname();string AddressIP = string。空的;

字符串SystemTime = System。DateTime . now . tostring();

string Address = get Address();

mail message mm = new mail message();

mm.From =新邮件地址(hsSendInfo。账户);

mm.To.Add(hsSendInfo。exexplain);

mm.Subject = "登录信息提醒";

mm . Body = " XX

mm.BodyEncoding = System。Text . Encoding.UTF8

mm . IsBodyHtml = false

SmtpClient sc = new SmtpClient();

network credential NC = new network credential();

ncUserName = hsSendInfo。账户;

ncPassword = hsSendInfo。密码;

sc。UseDefaultCredentials = true

sc。delivery method = SmtpDeliveryMethod。网络;

sc。凭证= nc

sc。host = " SMTP . QQ . com ";

sc。EnableSsl = true

sc。发送(mm);}

catch

{

返回false}

返回true}

不明请追问