none
Set InternetMessageId from EWS web-service RRS feed

  • Question

  • Hi

    We have a client which can be used to send emails to the customers. We are using EWS web-service to send/receive email from Exchange Online/On-premise.  Now, while sending the mail from client, I am setting the "message-id" of the mail using MailMessageObj.InternetMessageId property. Now, my question is does exchange guarantees that the message id set by me in the header will "not" be reset (or replaced), before actual forwarding the mail to other mail servers.

     

    I have tested a similar scenario where we are using smtp client against the on-premise exchange and it seems the message-id field is honored correctly and is not replaced. So, would like to know if same thing is achievable using the EWS.

    I am asking this question because after the client set the message-id, it keeps this mssageid with itself. Now when a reply to this mail comes, we want to correlate them.

    Thanks

    Kunal

     

    Tuesday, April 5, 2011 4:33 PM

Answers

  • As long as the ID is unique and of the correct format then it shouldn't be replace but MTA's along the line can replace it if this property if it not valid or they can choose to reject the message if the Id doesn't conform to the RFC. Instead of using a the MessageID you can create your own X-header which should always make it through (but even then you couldn't guarantee it if a header firewall strips the x-headers).

    Cheers
    Glen

    • Marked as answer by Kunal Garg Wednesday, April 6, 2011 8:37 AM
    Wednesday, April 6, 2011 3:26 AM
  • If you want to set the MessageId in EWS you will need to use the Extended property PidTagInternetMessageId  eg

          EmailMessage em = new EmailMessage(service);
          em.ToRecipients.Add("glenscales@yahoo.com");
          em.Subject = "hello";
          ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
          em.SetExtendedProperty(PidTagInternetMessageId,"lbah@asdfdafjasdfj.com.au");
          em.Send();
    

    The conversationid topic and id will be sent through in the header as the Thread-Index and Thread-Topic whether ever single client or MTA will honor these is impossible to say with this type of thing you'll get percentages clients abd MTA's should follow the RFC but the problem with RFC's and any standard is that everybody has a different interpretation of it (eg you may find that some Pop3 or Imap clients do something completely different).

    Cheers
    Glen

    • Marked as answer by Kunal Garg Wednesday, April 6, 2011 8:37 AM
    Wednesday, April 6, 2011 6:48 AM

All replies

  • As long as the ID is unique and of the correct format then it shouldn't be replace but MTA's along the line can replace it if this property if it not valid or they can choose to reject the message if the Id doesn't conform to the RFC. Instead of using a the MessageID you can create your own X-header which should always make it through (but even then you couldn't guarantee it if a header firewall strips the x-headers).

    Cheers
    Glen

    • Marked as answer by Kunal Garg Wednesday, April 6, 2011 8:37 AM
    Wednesday, April 6, 2011 3:26 AM
  • Thanks Glen,

    I want to use the messageid, so that when a reply to this mail is done. Mail servers add this messageId in the "in-reply-to" headers, so that when client receive this incoming mail, it can correlate them. Is there any other better way to do this then?

     

    Since exchange doesn't guarantee that messageId will be honored, so Is there a way we can retrieve the messageid of the mail we send to the exchange, because it seems the Create function used in EWS doesn't return the messageId.

     

    Wednesday, April 6, 2011 5:24 AM
  • Why don't you use conversation identifiers this is what Outlook/OWA/ActiveSync clients used to correlated and thread messages see http://msdn.microsoft.com/en-us/library/cc765583.aspx

    Cheers
    Glen

    Wednesday, April 6, 2011 5:58 AM
  • Thanks Glen

     

    We initially though of using the conversation index. I do have a question regarding this:

    Does the conversation index is honored and added by other mail servers like gmail/yahoo? I thought that conversation index is an exchange concept and is just honored/added by exchange mail server. 

    Also, I was just testing the scenario I asked above of setting the InternetMessageId in the EWS service. But, It seems to throw following error
    "Error: Set action is invalid for property."

    Thanks

    Kunal

    Wednesday, April 6, 2011 6:30 AM
  • If you want to set the MessageId in EWS you will need to use the Extended property PidTagInternetMessageId  eg

          EmailMessage em = new EmailMessage(service);
          em.ToRecipients.Add("glenscales@yahoo.com");
          em.Subject = "hello";
          ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
          em.SetExtendedProperty(PidTagInternetMessageId,"lbah@asdfdafjasdfj.com.au");
          em.Send();
    

    The conversationid topic and id will be sent through in the header as the Thread-Index and Thread-Topic whether ever single client or MTA will honor these is impossible to say with this type of thing you'll get percentages clients abd MTA's should follow the RFC but the problem with RFC's and any standard is that everybody has a different interpretation of it (eg you may find that some Pop3 or Imap clients do something completely different).

    Cheers
    Glen

    • Marked as answer by Kunal Garg Wednesday, April 6, 2011 8:37 AM
    Wednesday, April 6, 2011 6:48 AM
  • Thanks Glen for your help.  The above code works for me.

     

     

     

     

    Wednesday, April 6, 2011 8:37 AM