希望是一个非常简单的。我将一个应用程序.net-core
从.net
使用EWS
. 除了进行大量交互异步之外,所有似乎都可以正常工作而无需任何更改。除了从电子邮件下载附件。在调试和使用对象检查器时,FileAttachment
对象存在并且对象属性/大小看起来正是我所期望的。的FileAttachment
。Load
(string outputPath) 创建一个文件,但是,该文件的内容大小为 0KB。所以外壳已经创建,但没有数据流入其中。可能我错过了一些明显的东西,但明显的东西正在逃避我。尝试使用流和输出路径方法,结果相同。该功能在.net
框架版本中仍然可以正常工作。任何想法非常感谢?
foreach (EmailMessage email in orderedList)
{
EmailMessage message = await EmailMessage.Bind(_service, email.Id, new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.Attachments));
if (email.HasAttachments)
{
foreach (Attachment attachment in message.Attachments)
{
bool getFile = false;
if (attachment is FileAttachment)
{
FileAttachment fileAttachment = attachment as FileAttachment;
if (!string.IsNullOrEmpty(filename) && fileAttachment.Name.StartsWith(filename))
{
getFile = true;
}
else if (string.IsNullOrEmpty(filename))
{
getFile = true;
}
if (getFile)
{
//var response …
Run Code Online (Sandbox Code Playgroud)