We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Apostrophe in mail subject cause an error


I use version

I have created MailQuery object with

string pSubject = “12345’”;

ExchangeQueryBuilder qb = new ExchangeQueryBuilder();


MailQuery mailQ = qb.GetQuery();

Please mention the apostrophe in subject;

now I try to use method to list messages.

IEWSClient.ListMessages(folderUri, maxResult, mailQ);

method call fails on error:

System.Web.Services.Protocols.SoapException: The request failed schema validation: The element ‘Restriction’ in namespace ‘http://schemas.microsoft.com/exchange/services/2006/messages’ has incomplete content. List of possible elements expected: ‘SearchExpression, Exists, Excludes, IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo, Contains, Not, And, Or’ in namespace ‘http://schemas.microsoft.com/exchange/services/2006/types’.

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at Aspose.Email.Exchange.Schema.Exchange_2013.ExchangeServiceBinding.FindItem(FindItemType FindItem1)

at #=qFBZJNJeTrY4DOlsawgw1lNTee5c5eC2B3Vr0KGfVAHnkLfRDAWy6A3PKvu8enu8D.#=qGaV7HzMnlvWwqTc3c2GIFa8iZ$QarTsw_PLYsmSxniM=(ExchangeMessagePageInf…

I have tried to escape apostrophe character and use

string pSubject = “12345’”;

but have same result

If I use my code without apostrophe in query - all works fine

please advise solution.

Thanks a lot

Hi George,

Thank you for contacting Aspose support team.

I have tried following sample code and observed no issue using latest version Aspose.Email for .NET You may please give a try to the following sample code using latest library and share the feedback.

const string mailboxUri = https://outlook.office365.com/ews/exchange.asmx;<o:p></o:p>

const string domain = @"";

const string username = @"user@xyz.onmicrosoft.com";

const string password = @"password";

NetworkCredential credentials = new NetworkCredential(username, password, domain);

IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);

string pSubject = "12345'";

ExchangeQueryBuilder qb = new ExchangeQueryBuilder();


MailQuery mailQ = qb.GetQuery();

var mailBoxInfo = client.GetMailboxInfo();

var messages = client.ListMessages(mailBoxInfo.InboxUri, 10, mailQ);

I have downloaded latest version of Aspose.Email
and I face the same problem.

I work with Exchange 2013.

I have attached sample project and error.txt file

Thanks a lot for help


Hi George,

Thank you for providing sample application. This issue is re-produced here and logged under Id: EMAILNET-38653 for further investigation by the product team.

You will be automatically notified once any update is received in this regard.

The issues you have found earlier (filed as EMAILNET-38653) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello Aspose team,

Thanks for providing solution, however the problem is still there.
I have downloaded suggested version (
When I use string “12345’” (Apostrophe at the end of string) - it works fine
When I use string “12345’6” or “'6” (Apostrophe at the middle, or at the beginning of the string) - it fails on the same exception.
Please help to resolve this issue.
Thanks a lot

Hi George,

I have tested the scenario using Aspose.Email for .NET 17.3.0 and observed no issue (with subjects having apostrophe at start, middle and end). Could you please send us a complete project which along with the credentials of test account where such mails are present? It will help us to observe the issue and analyze it again.

Hello Kashif,

I have attached sample project
Thanks for help


We have reopened this ticket for further consideration by our Product team. We’ll update you here as there is some news available about the status of this issue.

We regret the inconvenience caused to you in this regard.