2015-08-24 94 views
0

我有一條帶有ebbedded消息的消息,該消息具有自己的附件。我必須使用EWS將其發送到服務器。我可以發送包含嵌入消息的消息作爲附件,但無法發送附件,因爲AttachmentType不允許向附件添加附件。你知道任何其他方式來解決我的問題嗎?在這種情況下如何使用EWS將附件添加到嵌入消息中

回答

0

一個解決辦法應該工作是使用ItemAttachment的MIMEContent例如

itemAttachment.Load(newPropertySet(ItemSchema.MimeContent));

然後創建基於該消息或添加作爲附件上的新的消息例如

 FolderId folderid= new FolderId(WellKnownFolderName.Inbox,"MailboxName");  
     Folder Inbox = Folder.Bind(service,folderid); 
     ItemView ivItemView = new ItemView(1) ;  
     FindItemsResults<Item> fiItems = service.FindItems(Inbox.Id,ivItemView); 
     if(fiItems.Items.Count == 1){ 
     EmailMessage mail = new EmailMessage(service); 
     EmailMessage OriginalEmail = (EmailMessage)fiItems.Items[0]; 
     PropertySet psPropset= new PropertySet(BasePropertySet.IdOnly);  
     psPropset.Add(ItemSchema.MimeContent); 
     psPropset.Add(ItemSchema.Subject); 
     OriginalEmail.Load(psPropset); 
     ItemAttachment Attachment = mail.Attachments.AddItemAttachment<EmailMessage>(); 
     Attachment.Item.MimeContent = OriginalEmail.MimeContent; 
     ExtendedPropertyDefinition PR_Flags = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);  
     Attachment.Item.SetExtendedProperty(PR_Flags,"1");  
     Attachment.Name = OriginalEmail.Subject; 
     mail.Subject = "See the Attached Email"; 
     mail.ToRecipients.Add("[email protected]"); 
     mail.SendAndSaveCopy();  

乾杯 格倫

相關問題