none
Journaling mailbox ServiceObjectPropertyException RRS feed

  • Question

  • Hi,

    I am working on exchange 2010 (sp1) and using EWS and trying to read mails from journaling mailbox.

    Below is the pseudo code:

    var MailBox = new Mailbox(SmtpAddress);

     FolderId folderId = new FolderId(WellKnownFolderName.Inbox, MailBox);

    foreach (Item item in findResults.Items)

    {

       if (item is EmailMessage)

      

       {

          ProcessMessage(item);

       }

    }

    Now in this ProcessMessage function I am copying the item data to my own email class

    foreach (Microsoft.Exchange.WebServices.Data.Attachment attachment in item.Attachments)

    {

       if (itemAttachment.Item is EmailMessage)

       {

    EmailMessage msg = (EmailMessage)itemAttachment.Item;

       //     Reading properties

       Myemail. Time = msg.DateTimeReceived;

       Myemail.subject  = msg.Subject;

      Myemail.sender = msg.Sender.Address;

      Myemail.MessageId = msg.InternetMessageId

       }

    }

    Now here I am getting ServiceObjectPropertyException while reading properties.

    Now here I am worried about InternetMessageId property and for few emails I am getting this exception. Offcourse I can read the message id from body of journaling email but I don’t want to do that as I have to set flags to check if it is attached email to journaling email or embedded email from original message.

    Any idea why InternetMessageId is giving exceptions? I can clearly see message ids for those emails in body of journaling email.

    Also some times the other three properties also throw exception.

    Regards,

    Amit

    Monday, July 29, 2013 6:13 PM

All replies

  • Hi All,

    I got answer why message id is getting null this is because we have some embeded messages which are not created on Exchange servers and for those code is unable to resolve the message id.

    Still trying to find out how to find out failed properties before the assignment such that I don't have to write code like below for each property:

    try

    {

     Myemail. Time =msg.DateTimeReceived;

    }

    catch(ServiceObjectPropertyException )

    {

    }

    Regards,

    Abhagwat

    Friday, August 2, 2013 9:16 AM
  • You can use TryGetProperty to see if property has been returned or not eg

                object Propval = null;
                if (msg.TryGetProperty(ItemSchema.DateTimeReceived, out Propval)) { 
                
                }
    Cheers
    Glen
    Monday, August 5, 2013 6:19 AM