Journaling mailbox ServiceObjectPropertyException

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 dont 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

July 29th, 2013 2:16pm

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

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2013 5:21am

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
August 5th, 2013 2:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics