May, 2011

  • Akash Blogging......

    "Internal Server Error" exception while updating Contact item on Exchange 2010 Mailbox using EWS

    • 0 Comments

    This was an interesting issue I ran into so thought of sharing it. One of my customer had written and application to synchronize contacts using Exchange Web Services, on some mailboxes he was getting an “Internal Server Error” while trying to update contacts.

    Error:
    Encountered unhandled exception: Microsoft.Exchange.Services.Core.Types.InternalServerErrorException: An internal server error occurred. The operation failed. ---> System.ArgumentNullException: Value cannot be null.
    Parameter name: address
       at Microsoft.Exchange.Data.SmtpAddress.IsValidSmtpAddress(String address)
       at Microsoft.Exchange.Data.Storage.JunkEmailRule.AddTrustedContact(String email, ADRecipientSession recipSession)
       at Microsoft.Exchange.Data.Storage.Contact.UpdateJunkEmailContacts()
       at Microsoft.Exchange.Data.Storage.Item.SaveInternal(SaveMode saveMode, Boolean commit)
       at Microsoft.Exchange.Services.Core.ServiceCommandBase.<>c__DisplayClass7.<SaveXsoItem>b__6(SaveMode saveModeDelegate)
       at Microsoft.Exchange.Services.Core.ServiceCommandBase.<>c__DisplayClass4.<ExecuteItemSave>b__3()
       at Microsoft.Exchange.Services.Core.ServiceCommandBase.ExecuteStoreObjectSave(SaveStoreObject saveStoreObject, Boolean useItemError)
       at Microsoft.Exchange.Services.Core.ServiceCommandBase.ExecuteItemSave(SaveItem saveItem, ConflictResolutionType conflictResolutionType)
       at Microsoft.Exchange.Services.Core.ServiceCommandBase.SaveXsoItem(Item xsoItem, SaveItem saveItem, ConflictResolutionType conflictResolutionType, PropertyDefinition[] propsToLoad)
    ...

    The exception did mention about  “Value cannot be null”  for the parameter “address” so we made sure that the email address was not blank.We tried to reproduce the issue with the same soap request but we were unable to. Although the format of the email address given in the contact was not correct we had no issue updating the contact in our test server. The strange part was that it was happening on only on a few mailboxes! What could be different?

    The call stack above gave me what I needed! Why are we trying to add a Trusted Contact? What has the Junk Email Rule got to do with it?

    Digging on the exchange 2010 side I came across cmd-let’s called “Get-MailboxJunkEmailConfiguration” and “Set-MailboxJunkEmailConfiguration”. To my joy the “Set-MailboxJunkEmailConfiguration” had a parameter called ContactsTrusted(System.Boolean) and it was sent to False in my environment. I set to true and then ran the test again and guess what?

    I get the same exception the customer was getting. The next step was to alter the email addresses in the SOAP request to valid ones and then, yes you guessed it right! Everything worked fine now!

    So you can basically have a crappy email address for a contact and get away with it if the ContactsTrusted is set to false, but if it’s set to true – You better have you email addresses for your contact right!

    -Enjoy

Page 1 of 1 (1 items)