切换到宽版
  • 4880阅读
  • 3回复

[求助]Exchange 邮箱服务器某些账号总是被自动锁住 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2016-07-06
是用C#开发的邮件发送功能总是出现如下错误“The request failed. 远程服务器返回错误: (401) 未经授权”
代码如下:

  1. public class ExchangeEmail
  2.     {
  3.         public ExchangeService service;
  4.         public ExchangeEmail()
  5.         {
  6.             service = new ExchangeService(ExchangeVersion.Exchange2010);
  7.             service.Credentials = new WebCredentials("mailAddress", "PWD", "Domain");
  8.             service.Url = new Uri("https://domain/ews/exchange.asmx");
  9.             service.TraceEnabled = true;
  10.             service.TraceFlags = TraceFlags.All;
  11.             
  12.         }
  13.         Logger log = new Logger();
  14.         public bool SendEmail(string SendTo, string EmailSubject, string EmailBody, string CCTo = "", string AttachmentName = "", byte[] AttachStream = null)
  15.         {
  16.             EmailMessage email = new EmailMessage(service);
  17.             try
  18.             {
  19.                 if (SendTo.IndexOf(";") > 0)
  20.                 {
  21.                     string[] EmailArray = SendTo.Split(';');
  22.                     foreach (string item in EmailArray)
  23.                     {
  24.                         email.ToRecipients.Add(item.TrimEnd().TrimStart());
  25.                     }
  26.                 }
  27.                 else
  28.                 {
  29.                     email.ToRecipients.Add(SendTo.TrimEnd().TrimStart());
  30.                 }
  31.                 if (CCTo != "")
  32.                 {
  33.                     if (CCTo.IndexOf(";") > 0)
  34.                     {
  35.                         string[] EmailArray = CCTo.Split(';');
  36.                         foreach (string item in EmailArray)
  37.                         {
  38.                             email.ToRecipients.Add(item.TrimEnd().TrimStart());
  39.                         }
  40.                     }
  41.                     else
  42.                     {
  43.                         email.CcRecipients.Add(CCTo.TrimEnd().TrimStart());
  44.                     }
  45.                     log.Log("Add CC Recipient " + CCTo + "  Successfully");
  46.                 }
  47.                 if (AttachmentName != "" && AttachStream != null)
  48.                 {
  49.                     email.Attachments.AddFileAttachment(AttachmentName, AttachStream);
  50.                 }
  51.                 email.Subject = EmailSubject;
  52.                 email.Body = new MessageBody(EmailBody);
  53.                 email.Body.BodyType = BodyType.HTML;
  54.                 email.Send();
  55.                 return true;
  56.             }
  57.             catch (Exception)
  58.             {
  59.                 return false;
  60.             }
  61.             finally
  62.             {
  63.                 email.ToRecipients.Clear();
  64.                 email.CcRecipients.Clear();
  65.                 email.BccRecipients.Clear();
  66.             }
  67.         }
  68.     }


当执行完方法之后 再进入服务器上查看对应的账号状态会发现状态如下图:


正常情况下 状态如下:


谁知道这是什么原因造成的??
分享到
只看该作者 1楼  发表于: 2016-07-06
Re:Exchange 邮箱服务器某些账号总是被自动 ..
自己顶一下,跪求大神指导。
只看该作者 2楼  发表于: 2016-07-06
Re:Exchange 邮箱服务器某些账号总是被自动 ..

只看该作者 3楼  发表于: 2016-07-06
回 aaronwang 的帖子
aaronwang:[表情] ?(2016-07-06 15:53)?

被锁的账户是发件人账户么?我看了下代码没有把发件人密钥写在里面,那就是匿名邮件咯?这需要在接受连接器上开相应的验证通道。
Exchange中文站10周年献礼。Exchange2016中文视频教程热销中:edu.exchangecn.com/course/12
快速回复
限60 字节
 
上一个 下一个