C#程序做发送邮件时出现错误提示

来源:百度知道 编辑:UC知道 时间:2024/06/23 04:08:38
用google的帐号做发送邮件的程序时出错误提示怎么回事。请讲得详细点,
讲得好的,加分到50。

google的Gmail发送邮件需要安全认证的,你在发信时,要指定SmtpClient的Credential:

CredentialCache myCache = new CredentialCache();
myCache.Add("SMTP主机地址", 25, "login", new NetworkCredential("你在邮件服务器上的用户名", "你在邮件服务器上的密码"));
smtpClient.Credentials = myCache;

然后再
smtpClient.Send();