问题描述
我的asp.net控制台应用程序中有以下代码,可使用Office 365 SMTP服务器发送电子邮件:-
static private void sendemail(ClientContext context,string subject,string body,string to)
{
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("sharepoint@outorganization.com");
mail.Subject = subject;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "ourorganization-com.mail.protection.outlook.com";
smtp.EnableSsl = true;
mail.Body = body;
mail.To.Add("***@****.net");
smtp.Port = 25;
smtp.Send(mail);
}
}
static void Main(string[] args)
{
string s = "******";
securestring passWord = new securestring();
foreach (var cc in s)
passWord.AppendChar(cc);
using (ClientContext context = new ClientContext("https://****.sharepoint.com/"))
{
context.Credentials = new SharePointOnlineCredentials("***@***.onmicrosoft.com",passWord);
sendemail(context,"test 123","test123 body","***@***.net");
}
}
但是smtp.Send(mail);
引发以下错误,根据在以下代码中运行上述代码的服务器,我得到了不同的错误:-
错误1
System.Net.Mail.SmtpException: 'Error in processing. The server response was: 4.4.62 Mail sent to the wrong Office 365 region. ATTR35. For more information please go to https://go.microsoft.com/fwlink/?linkid=865268 [HE1EUR01FT009.eop-EUR01.prod.protection.outlook.com]'
错误2
MailBox unavailable. The server response was: 5.7.1 Service unavailable,Client host [165.225.80.126] blocked using Spamhaus. To request removal from this list see https://www.spamhaus.org/query/ip/165.225.80.126 AS(1450) [VE1EUR01FT009.eop-EUR01.prod.protection.outlook.com]
对此有什么建议吗? 谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)