I am not able to send a mail which has a email report (read/delivery... receipts) and distribution list as an attachment. I am using the AddItemAttachment<> API as mentioned in the sample application present on MSDN.
For example I tried the following ways -
- When I try to use ContactGroup as the template class in the method, it fails with the error -"Items of type ContactGroups are not supported as attachments" , when I call the final SaveAndSend.
EmailMessage email = new EmailMessage(service); email.ToRecipients.Add("user@contoso.com"); ItemAttachment<ContactGroup> itemAttachment = email.Attachments.AddItemAttachment<ContactGroup>(); email.SendAndSaveCopy();
- If I try to add the attachment with the Item class as the template class and then manually change the message class, it fails with the error-"Operation would change object type, which is not supported", when I call the final SaveAndSend.
I have also tried to set the extended MAPI property PR_MESSAGE_CLASS
EmailMessage email = new EmailMessage(service); email.ToRecipients.Add("user@contoso.com"); ItemAttachment<Item> itemAttachment = email.Attachments.AddItemAttachment<Item>(); itemAttachment.Item.ItemClass = "IPM.DistList"; email.SendAndSaveCopy();
- If I try add the attachment with the Item class and then do not manually change the the class, the final SaveAndSend succeeds but the attachment is created as a sticky note.
EmailMessage email = new EmailMessage(service); email.ToRecipients.Add("user@contoso.com"); ItemAttachment<Item> itemAttachment = email.Attachments.AddItemAttachment<Item>(); email.SendAndSaveCopy();
I am facing a similar problem with email reports (I use method 2 and try to change the message class manually). I am using Exchange 2013 CU2 on a Win 2012 server. Can someone suggest the correct method?
Thanks.
- NYA