Internet Message ID FROM EWS Managed API Send Email c#

喜你入骨 提交于 2019-12-04 05:32:46

问题


I am trying to discover if there is a way to determine the internet message ID after sending an email using the EWS Managed API. I understand you can go in there and get the results from the sent box, but the server that is sending these emails is sending multiple emails at a time from different services.


回答1:


No you can't, basically because EWS sends message Asynchronously the Id isn't available see https://social.msdn.microsoft.com/Forums/azure/en-US/dd034b8c-ffa1-4ae0-9025-45fcf520c9e5/updateitem-does-not-return-itemid?forum=exchangesvrdevelopment

As a work around you might want to consider setting the Internet messageId on the Message before you send it. As long as it valid and unique it should work okay eg

        ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
        EmailMessage ema = new EmailMessage(service);
        ema.Subject ="test from ews";
        ema.Body = new MessageBody("test<br>Rgds<>");
        ema.ToRecipients.Add("gscales@domain.com");
        ema.SetExtendedProperty(PidTagInternetMessageId,("<" +Guid.NewGuid().ToString() + "@domain.com>"));
        ema.SendAndSaveCopy();

Also if you save the message first as a draft before sending it the server will assign the MessageId property which which should then be able to read back using Load.

Cheers Glen



来源:https://stackoverflow.com/questions/35073995/internet-message-id-from-ews-managed-api-send-email-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!