C# 无法绑定 EmailMessage
C# Unable to Bind EmailMessage
我有一个方法可以将 Email
格式转换为 .eml
格式。
但是,EmailMessage.Bind
的语句突然停止工作,没有任何错误。
下面是我的代码片段:
public static string convertEmailToEml(EmailMessage emailMessage, string caseNumber, string EMLSaveFilePath)
{
Console.WriteLine(emailMessage.Subject); //correct value
Console.WriteLine(caseNumber); //correct value
Console.WriteLine(EMLSaveFilePath); //correct value
Console.WriteLine(emailMessage.Id); //correct value
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
PropertySet props = new PropertySet(EmailMessageSchema.MimeContent);
var email = EmailMessage.Bind(service, emailMessage.Id, props); //not executed
string emlFullPath = EMLSaveFilePath + caseNumber + ".eml"; //not executed
Console.WriteLine(emlFullPath); //code not reached
Console.ReadKey();
using (FileStream fs = new FileStream(emlFullPath, FileMode.Create, FileAccess.Write))
{
fs.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length);
}
return emlFullPath;
}
请问有什么可以看的地方吗?
在构建解决方案时有 warning
条消息如下,不确定它们是否链接:
Found conflicts between different versions of the same dependent
assembly that could not be resolved. These reference conflicts are
listed in the build log when log verbosity is set to detailed.
调试模式期间抛出的异常:
'Microsoft.Exchange.WebServices.Data.ServiceLocalException' in
Microsoft.Exchange.WebServices.dll("The Url property of the
ExchangeService object must be set.")
我已验证 service
、emailMessage.Id
和 props
值不是 null
。
根据 the documentation for `EmailMessage.Bind(...),它声明此方法会调用 Exchange Web 服务 (EWS)。
您创建了 ExchangeService
的实例,但没有向其提供 URL (documentation)。这是一个要求。抛出的异常直接指向丢失的数据。
我有一个方法可以将 Email
格式转换为 .eml
格式。
但是,EmailMessage.Bind
的语句突然停止工作,没有任何错误。
下面是我的代码片段:
public static string convertEmailToEml(EmailMessage emailMessage, string caseNumber, string EMLSaveFilePath)
{
Console.WriteLine(emailMessage.Subject); //correct value
Console.WriteLine(caseNumber); //correct value
Console.WriteLine(EMLSaveFilePath); //correct value
Console.WriteLine(emailMessage.Id); //correct value
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
PropertySet props = new PropertySet(EmailMessageSchema.MimeContent);
var email = EmailMessage.Bind(service, emailMessage.Id, props); //not executed
string emlFullPath = EMLSaveFilePath + caseNumber + ".eml"; //not executed
Console.WriteLine(emlFullPath); //code not reached
Console.ReadKey();
using (FileStream fs = new FileStream(emlFullPath, FileMode.Create, FileAccess.Write))
{
fs.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length);
}
return emlFullPath;
}
请问有什么可以看的地方吗?
在构建解决方案时有 warning
条消息如下,不确定它们是否链接:
Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
调试模式期间抛出的异常:
'Microsoft.Exchange.WebServices.Data.ServiceLocalException' in Microsoft.Exchange.WebServices.dll("The Url property of the ExchangeService object must be set.")
我已验证 service
、emailMessage.Id
和 props
值不是 null
。
根据 the documentation for `EmailMessage.Bind(...),它声明此方法会调用 Exchange Web 服务 (EWS)。
您创建了 ExchangeService
的实例,但没有向其提供 URL (documentation)。这是一个要求。抛出的异常直接指向丢失的数据。