我是Asp.net
的新手,我需要使用我的Outlook
發送來自Asp.net
的電子郵件。 我有一個按鈕在asp中,當我點擊按鈕(發送)我想發送電子郵件。 我試圖使用Hotmail和Gmail
但遠程服務器處於阻塞狀態。 如果你不明白我的問題,請告訴我。 我嘗試這樣做:如何發送電子郵件
var smtpClient = new SmtpClient
{
Host = "outlook.mycompany.local",
UseDefaultCredentials = false,
Credentials = new NetworkCredential("[email protected]", "myPassword")
};
var message = new System.Net.Mail.MailMessage
{
Subject = "Test Subject",
Body = "FOLLOW THE WHITE RABBIT",
IsBodyHtml = true,
From = new MailAddress("[email protected]")
};
// you can add multiple email addresses here
message.To.Add(new MailAddress("[email protected]"));
// and here you're actually sending the message
smtpClient.Send(message);
}
Exeption顯示:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
請我該怎麼辦呢?
世界觀,你實際上意味着交易?如果Outlook沒有連接到電子郵件服務器,它就不能發送電子郵件,它只是一個客戶端。 –
你必須使用EmailFrom,EmailTo等的實際值。同時確保EmailFrom是SMTP服務器識別和允許的地址,否則它將被阻止爲垃圾郵件嘗試 –
@DimitarDimitrov是它連接到電子郵件服務器。我們是公司,我們使用outlook來溝通。我需要從asp發送電子郵件給所有人。這是我的任務:S –