ms dynamics 4.0 - email with apostrophe in it


i am programatically creating a contact in crm 4.0.
i am using a windows service which calls into a wsdl generated proxy of the crm webservice.
it works fine - but when i create a contact which has an email address that contains an apostrophe. i.e

contact crmContact = new contact();
contact.emailaddress1 = "sean.o'";
//add other properties...

//this is an instance of my proxy

it always falls over with the following soap exception:

2011-03-16 16:06:56,448 [7] ERROR  [(null)] - Soap Exception in :mywindowsservice Error : <error>
<description>An unexpected error occurred.</description>

I have tried escaping the apostrope with  sean.o\' - but i still get the same exception.

thankyou very much.

Who is Participating?
smartappConnect With a Mentor Commented:

As solution for the problem, you can call crmservice by replacing apostrophe bu others acceptable characters, for example :

contact.emailaddress1 = "";

And register a new Prestage plugins on create message on contact entity and replace -.- by the apostrophe '.

contact.emailaddress1 = contact.emailaddress1.Replace("-.-","'");

Hope this will solve your problem

MrKevorkianConnect With a Mentor Author Commented:

thanks for your suggestion.  I have just figured out the problem!

basically just sending apostrophes through the webservice is actually fine.
but what i was doing in my code, before creating a contact - i was running a fetchxml query, to check that the contact email did not already exist.  And the apostrophe in the email was breaking the fetch x ml - so what i did was encode it

and this still retrieved sean.o'brien  at the crm end!

so it was the fetch query that was the problem.

MrKevorkianAuthor Commented:
MrKevorkianAuthor Commented:
it was a really good suggestion, that got me thinking, which led to me solving my problem.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.