使用EWS Exchange创建电子邮件并附加另一封电子邮件 [英] Create an email using EWS Exchange and attach another email

查看:130
本文介绍了使用EWS Exchange创建电子邮件并附加另一封电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用EWS将电子邮件附加到新电子邮件上.

I'm having trouble attaching an email to a new email using EWS.

所以我的findResults中有Microsoft.Exchnage.Webservice.Data.Item.

So i have the Microsoft.Exchnage.Webservice.Data.Item in my findResults.

如果我在电子邮件的表单数据中发现问题,那么我想将该项目附加到新电子邮件中,然后将其发送给主管以进行手动输入.

If I find an issue in the form data of the email then I want to attach that item to a new email and send it to a supervisor for manual input.

我已经尝试过了

EmailMessage newMessage = new EmailMessage(exchange);
newMessage.Subject = "Failed lead creation";
ItemAttachment attachment = new ItemAttachment("New Lead", message);

我似乎无法创建ItemAttachment,因为我得到的错误是"ItemAttachment不包含带有2个参数的构造函数".

I can't seem to create the ItemAttachment as the erro I am getting is "ItemAttachment does not contain a constructor that takes 2 arguments".

如何在EWS中创建新消息,将当前项目附加到该消息并发送给另一个收件人?

How do I create a new message in EWS, attach the current Item to it and send to another recipient?

Thaks

推荐答案

您不能直接使用其他消息,而需要使用原始消息的MimeContent,然后基于该消息创建ItemAttachment,例如类似

You can't another message directly you need to use the MimeContent of the Original Message and then create an ItemAttachment based on that eg something like

    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();     

欢呼 格伦

这篇关于使用EWS Exchange创建电子邮件并附加另一封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆