none
Retrieving email using Exchange Web Services problem RRS feed

  • Question

  • Hi,

    After connecting to exchange and filter the emails

    ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2013_SP1);

    foreach (EmailMessage message in unreadMessages)
    {
    message.Load();
    string temp = message.Subject;
    }

    the strange thing is that my email subject is not the one that is send for example, if i send a email with the subject DEMO|502|Marcio|20150909|10|1‏00 when i do message.Subject it returns DEMO|502|Marcio|20150909|10|‏001
    When i split the message.Subject string by the | and try to convert the last string to int32 it gives a error saying that it cant convert.

    When i convert the subject to charArray i get an extra char between the last "1" and "00", unicode 8207, an right to left mark.

    Is there any way to remove this and get the correct subject (DEMO|502|Marcio|20150909|10|1‏00). 

    Best Regards, Pedro Soeiro.

    • Moved by CoolDadTx Friday, September 11, 2015 4:59 PM Exchange related
    Friday, September 11, 2015 11:03 AM

All replies

  • Friday, September 11, 2015 3:39 PM
  • The left to right mark is there for a purpose eg you have sent that message from a client or Mailbox that has the regional setting set to a language like Hebrew etc that flows right to left (on a normal US English mailbox you won't see this).  Exchange will return what it has stored the (control mark)left to right mark should be the first thing in the string eg I would suggest you look at the one of the offending subjects with a Mapi editor you should see something like

    (in your case you want to look at the Subject property). If you don't want the control character in the script then you will need to write your own code to deal with that.

    Monday, September 14, 2015 4:35 AM
  • The below forum is where you need to post.

    https://social.msdn.microsoft.com/Forums/Lync/en-US/home?category=exchangeserver

    Sorry about that.

    The left to right mark is there for a purpose eg you have sent that message from a client or Mailbox that has the regional setting set to a language like Hebrew etc that flows right to left (on a normal US English mailbox you won't see this).  Exchange will return what it has stored the (control mark)left to right mark should be the first thing in the string eg I would suggest you look at the one of the offending subjects with a Mapi editor you should see something like

    (in your case you want to look at the Subject property). If you don't want the control character in the script then you will need to write your own code to deal with that.

    We'r removing all the hidden chars from the subject by code.

    Regex.Replace(message.Subject, @"[^\x20-\x7F]", "");

    Thanks.


    • Edited by errors32 Tuesday, September 15, 2015 8:51 AM
    Tuesday, September 15, 2015 8:17 AM