Internet Message ID FROM EWS Managed API Send Email c#

后端 未结 1 594
不思量自难忘°
不思量自难忘° 2021-01-25 01:01

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 res

相关标签:
1条回答
  • 2021-01-25 01:36

    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

    0 讨论(0)
提交回复
热议问题