We’re have a sporadic problem with EWS mail users. In the stack trace we see
System.ArgumentException: Requested value 'GroupMailbox' was not found.'
Findings
This is the StackTrace :
at System.Enum.TryParseEnum (System.Type enumType, System.String value, Boolean ignoreCase, System.EnumResult& parseResult) <0x10087d640 + 0x0052b>
in <filename unknown>:0
at System.Enum.Parse (System.Type enumType, System.String value, Boolean ignoreCase) <0x1006b91a8 + 0x00057>
in <filename unknown>:0
at Microsoft.Exchange.WebServices.Data.EwsUtilities.Parse[T] (System.String value) <0x10114e1ac + 0x000e3>
in <filename unknown>:0
at Microsoft.Exchange.WebServices.Data.EwsXmlReader.ReadValue[T] () <0x10114e764 + 0x00053>
in <filename unknown>:0
at Microsoft.Exchange.WebServices.Data.EwsXmlReader.ReadElementValue[T] () <0x10114e078 + 0x00087>
in <filename unknown>:0
at Microsoft.Exchange.WebServices.Data.EmailAddress.TryReadElementFromXml (Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader reader) <0x1010a4330 + 0x00187>
at Microsoft.Exchange.WebServices.Data.EmailAddress.TryReadElementFromXml (Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader reader) <0x1010a4330 + 0x00187>
In the source we thing this method EmailAddress :: TryReadElementFromXml
case XmlElementNames.MailboxType:
this.mailboxType = reader.ReadElementValue<MailboxType>();
Analysis:
We believe that for some messages a MailboxType enum is trying to be parsed. However the enum MailboxType does not contain the value GroupMailbox and therefore throws an exception.
This is the documentation for the MailboxType enum
Is it possible that the server logic was updated on the enum was not kept up-to-date???
Furthermore:
Also we’ve traced it down to the method in EWSUtilities.cs
internal static T Parse<T>(string value)
The else clause is
else
{
return (T)Enum.Parse(typeof(T), value, false);
}
Which should be reserved for when the enumeration is not found??? And instead of doing a TryParse its doing a Parse which fails.
This apparently is also a bug???
The Source for the EWS Managed API is on GitHub and I believe this has been updated with then new Enum https://github.com/OfficeDev/ews-managed-api/blob/154dbc66ac018d861c73ce489839cd9f58a1b0cd/Enumerations/MailboxType.cs . You should be compiling and using the latest source from GitHub as the latest release version and NuGet version released predates the change. (Microsoft should really be updating NuGet package to avoid issues).