當附件是電子郵件時,我可以簡單地獲取MIME內容並保存它。但是當附件是聯繫人時,我無法獲得MimeContent。下面是代碼如何使用EWS API下載電子郵件附件中的聯繫人?
itemAttachment.Load(new PropertySet(ItemSchema.MimeContent)); MimeContent mc = itemAttachment.Item.MimeContent; //Convert it to bytes byte[] contentBytes = mc.Content;
當附件是接觸我正在異常下面
Microsoft.Exchange.WebServices.Data.ServiceResponseException發生 的HResult = -2146233088消息= MIME不支持轉換爲 此項目類型。 Source = Microsoft.Exchange.WebServices StackTrace: at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary() at Microsoft.Exchange.WebServices.Data.ServiceResponse.ThrowIfNecessary() at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest 附件,可空
1 bodyType, IEnumerable
1 additionalProperties, ServiceErrorHandling ErrorHandling中) 在Microsoft.Exchange.WebServices.Data.ExchangeService.GetAttachment(附件 附件,可空1 bodyType, IEnumerable
1 additionalProperties) 在Microsoft.Exchange.WebServices.Data.Attachment.InternalLoad (可空值1 bodyType, IEnumerable
1個附加屬性) 在Microsoft.Exchange.WebServices.Data.ItemAttachment.Load(IEnumerable`1 additionalProperties) 在Presensoft.JournalEmailVerification.EmailVerification.DownloadFailedAttachments(EmailMessage 味精,JournalEmail journalEmail)在C:\用戶\薩米爾\ Presensoft \電子郵件 歸檔\ Presensoft.JournalEmailVerification \ EmailVerification.cs:行 605的InnerException:
什麼是下載並保存聯繫人附件的正確方法?
我的要求是在文件系統中的附件保存爲獨立的文件。任何方式來實現這一目標? – Sameer
我能夠得到MimeContent並用我的測試代碼保存文件。我更新了答案,在確定附件是ItemAttachment並且附件的ItemClass是IPM.Contact後添加了我使用的兩行代碼。 –
Bob,itemAttachment.Load(new PropertySet(ItemSchema.MimeContent))和itemAttachment.Load(ItemSchema.MimeContent)有什麼區別? – Sameer