Cannot Access Nested Error Code From EWS Related Exceptions (C# .NET)

Hi,

I am currently evaluating the Email.Net product as we looking into saving/uploading .msg files content into an Exchange Online mailbox using the Exchange Web Services (EWS) client.

I was successful so far in regards to saving the .msg content in the mailbox, however I’ve been recently facing and issue: The exceptions thrown have a generic message like

An internal server error occurred. The operation failed.

which I know comes from the EWS response.

I investigated further and found out that the actual issue was that the mailbox was full which is identified by EWS with the ErrorQuotaExceeded error code as seen below:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Header>
	<h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="5791" MinorBuildNumber="27" Version="V2018_01_08"
		xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
	</s:Header>
	<s:Body>
		<m:CreateItemResponse
			xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
			<m:ResponseMessages>
				<m:CreateItemResponseMessage ResponseClass="Error">
					<m:MessageText>An internal server error occurred. The operation failed.</m:MessageText>
					<m:ResponseCode>ErrorInternalServerError</m:ResponseCode>
					<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
					<m:MessageXml>
						<t:Value Name="InnerErrorMessageText">The process failed to get the correct properties.</t:Value>
						<t:Value Name="InnerErrorResponseCode">ErrorQuotaExceeded</t:Value>
						<t:Value Name="InnerErrorDescriptiveLinkKey">0</t:Value>
					</m:MessageXml>
					<m:Items/>
				</m:CreateItemResponseMessage>
			</m:ResponseMessages>
		</m:CreateItemResponse>
	</s:Body>
</s:Envelope>

My question is: Is there a way to get the actual error reason instead of a generic message?

Many thanks,
LPires

Hello, @LPires

Since the exception occurs on the server side, we cannot affect the configuration for more detailed output. Perhaps there are some EWS options that allows to display a more detailed log.

Thank you.

Thank you @DmitryS for your quick response.

I understand the exception occurs on the server side.

The original post contains the actual SOAP response when I tried to upload/save a message into a full mailbox using the EWS SDK. That means the EWS server sends a descriptive response of what went wrong.

I even tried creating a message by building the SOAP .xml by hand and I received the exact same SOAP response as shown in the original post.
When I used the EWS SDK an exception was thrown and the exception contained the expected error code.

On the other hand, when I use Email.Net the ExchangeException exception that is thrown does not contain specific info regarding the failed operation.

I was expecting for ExchangeException.ErrorDetails to have the specific error code as received in the SOAP response.

BR,
LPires

@LPires

Thank you for the clarification. Have you tried enabling EwsClient activity logging as described at Activity Logging in EWS Client ?

@DmitryS

I had already done so. I went ahead and tried it a couple of times a few minutes ago to no success.

In the logs I can find the request - headers and .xml -, however for the response the headers are present, but not .xml content.

I am using this version:

<PackageReference Include="Aspose.Email" Version="22.7.0" />

BR,
LPires

@LPires

Ok, I have created the EMAILNET-40876 to implement the accessing of nested error code.

Thanks.

1 Like

@DmitryS

Many thanks.