我有一个带有ebbedded消息的消息,它有自己的附件。我必须使用EWS将此发送到服务器。我可以发送带有嵌入式邮件作为附件的邮件,但是不能发送它的附件,因为AttachmentType不允许在附件中添加附件。你知道其他的方法来解决我的问题吗?
在这种情况下,应该可以使用ItemAttachment的MIMEContent,例如
itemAttachment.Load(newPropertySet(ItemSchema.MimeContent));
,然后在此基础上创建一个Message或将其作为新消息的附件添加,例如
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("glen.scales@domain.com");
mail.SendAndSaveCopy();
干杯格伦