【发布时间】:2013-05-26 01:59:01
【问题描述】:
我是Asp.net 的新用户,我需要使用我的Outlook 从Asp.net 发送电子邮件。
我在 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);
}
异常显示: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,您实际上是指 Exchange 吗?如果 Outlook 没有连接到电子邮件服务器,它就无法发送电子邮件,它只是一个客户端。
-
EmailFrom、EmailTo 等必须使用真实值。还要确保 EmailFrom 是 SMTP 服务器识别并允许的地址,否则将被视为垃圾邮件尝试而被阻止
-
@DimitarDimitrov 是的,它已连接到电子邮件服务器。我们是公司,我们使用 Outlook 进行交流。我需要从 asp 向每个人发送电子邮件。这是我的任务:S
-
@PeterrPann 对不起,我脑子里一片空白