MailMessage mail = new MailMessage(fromAddress,toAddress);
mail.Subject = title3;
mail.Body = text3;
SmtpClient sc = new SmtpClient(smtpAddress);
sc.Credentials = new NetworkCredential(username,password);
sc.Send(mail);这是我在正常使用的代码
mail.Subject = title3;
mail.Body = text3;
SmtpClient sc = new SmtpClient(smtpAddress);
sc.Credentials = new NetworkCredential(username,password);
sc.Send(mail);这是我在正常使用的代码
用一下SendSendAsync();方法发送
订阅事件,在发送完进入SendCompletedCallback方法,看看有什么问题
smtp.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
public static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.ToString());
}
}我没有Try过外网的邮件发送,首先需要你在Domin支持,允许你连接,或者有代理
LZ再试试,Smtp认证是否通过
楼上的,这不就是帐号、密码我觉得还是连接Smtp的问题,像网域,代理的问题。像我们公司刚Try了一下,就连接不上外网的Server关注,等高手解决!