我创建了一种发送电子邮件的方法,例如:
public async Task SendEmailCC(string body, string subject, List<string> mainRecievers, List<string> receivers)
{
SmtpClient client = new SmtpClient("smtp-mail.outlook.com")
{
UseDefaultCredentials = true,
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("Test@gmail.com", "MyMailPassword")
};
MailMessage mailMessage = new MailMessage { From = new MailAddress("job@test.org") };
foreach (var reciever in mainRecievers)
{
mailMessage.To.Add(reciever);
}
foreach (var item in receivers)
{
mailMessage.CC.Add(item);
}
mailMessage.Body = body;
mailMessage.IsBodyHtml = true;
mailMessage.Subject = subject;
await client.SendMailAsync(mailMessage);
}
为了测试,我给自己发了一封电子邮件,但我没有收到电子邮件。我怎样才能找到我的问题?
我的例外是连接身份验证。
拉莫斯之舞
相关分类