我是新来的Asp.net
,我需要Asp.net
使用我的Outlook
. 我在 asp 中有一个按钮,当我单击按钮(发送)时,我想发送电子邮件。我尝试使用 Hotmail,Gmail
但远程服务器被阻止。如果你不明白我的问题,请告诉我。我试过这个:
var smtpClient = new SmtpClient
{
Host = "outlook.mycompany.local",
UseDefaultCredentials = false,
Credentials = new NetworkCredential("myEmail@mycommpany.com", "myPassword")
};
var message = new System.Net.Mail.MailMessage
{
Subject = "Test Subject",
Body = "FOLLOW THE WHITE RABBIT",
IsBodyHtml = true,
From = new MailAddress("myemail@mycommapny.com")
};
// you can add multiple email addresses here
message.To.Add(new MailAddress("friendEmail@Company.com"));
// and here you're actually sending the message
smtpClient.Send(message);
}
Exeption Show:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
请问我该怎么做?