每当我尝试通过EWS发送包含以下代码的邮件时,我都会得到例外:"' MessageDisposition'必须设置为SaveOnly'"。 (SendAndSaveCopy也这样做)
public static void SendMail(string from, string to, string subject, string body)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl(from, RedirectionUrlValidationCallback);
try
{
EmailMessage message = new EmailMessage(service);
message.IsAssociated = true;
message.ToRecipients.Add(new EmailAddress(to));
message.Subject = subject;
message.Body = body;
message.Send();
}
catch (Exception ex)
{
new ExceptionMessageBox(ex, "Unable to send Mail: " + subject).Show();
}
}
有人知道为什么会发生这种情况以及如何解决这个问题吗?
答案 0 :(得分:1)
你不应该这样做
message.IsAssociated = true;
当您发送的邮件仅对在文件夹中创建FAI(文件夹配置项目)有效时,该功能无效