Home » SQL Server

special characters in email addresses


Is there a manner to use e-mail addresses with special characters with the System.Net.Mail.MailAddress class?
For example françois.démontè@test.com.

Because mostly you get an System.FormatException:
System.FormatException: The specified string is not in the form required for an e-mail address.
   at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName)
   at System.Net.Mail.MailAddress.ParseValue(String address)
   at System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding)

Someone a solution for this problem?
Thanks in advance.

Kind regards,


3 Answers Found


Answer 1

Try this:

new MailAddress("françois.démontè@test.com","françois démontè", Encoding.Default)

or switch it to Encoding.Unicode



Answer 2

This is definitely a tricky part.

I set as value for the To address  françois.démontè@test.com and my real address and I receive the mail  (at my real inbox), but there is just one address in the To field and that is my real address.

So I can't control the accomplishment of the mail sent to françois.démontè@test.com.
I want to test it with a real address but I can't create one at my mailhost with those characters.

One good thing is that there are no exceptions are thrown.




Answer 3

Hi crmkr,


Welcome to MSDN Forums!


I think you need use this Encoding Class to change the string format, and then use it in the constructor.

string s = "test string";

string utf8_string = [dest Encoding].GetString([original Encoding].GetBytes(s));


PS:@Stuart Phillips

The third parameter is used to encoding  the display name not the email  address.

MailAddress Constructor (String, String, Encoding)



Can you share your code? We want to know your method. If you put the email address  in the constructor directly or after change the encoding?

Thank you.


If you have anything unclear, please feel free to let me know.


Have a nice weekend!



Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to the others community members reading the thread.



Hi there,


We're having an issue with some emails not being populated to CRM


Incoming emails to the CRM Forward Mailbox are normally processed and then removed form the mailbox but emails with + signs or invalid characters in the subject are not being processed and the Email Router is logging the following error on the CRM server



Event Type:      Error

Event Source:  MSCRMEmailLog

Event Category:           None

Event ID:          0

Date:                14/10/2010

Time:               09:08:57

User:                N/A

Computer:        Server



#27938 - An error occurred while checking for e-mail messages to process in mailbox CRMFORWARD@XXXXXX.com. System.Net.WebException: The remote server returned an error: (404) Not Found.

   at System.Net.HttpWebRequest.GetResponse()

   at Microsoft.Crm.Tools.Email.Providers.HttpDavRequest.SubmitXmlCommand(HttpWebRequest httpWebRequest, String body)

   at Microsoft.Crm.Tools.Email.Providers.HttpDavRequest.RetrieveMessage(ServiceLogger serviceLogger)

   at Microsoft.Crm.Tools.Email.Providers.ExchangePollingMailboxProvider.RetrieveNextMessageInternal()

   at Microsoft.Crm.Tools.Email.Providers.CrmPollingMailboxProvider.RetrieveNextMessage()

   at Microsoft.Crm.Tools.Email.Providers.CrmPollingMailboxProvider.Run()


For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


After doing some research and finding a couple of websites, I've found this possible solution:


With Exchange 2007 running on a Windows Server 2008 box, there is a known issue with Forward Mailbox not correctly processing emails containing special characters, such as the '+' symbol in the subject line.  The email router 'hangs' on the email in question and fails to process it and subsequent messages.

In addition to the email sticking in the mailbox, the Application Log on the server running the Email Router will log 404 errors for MSCRMEmail.  The exact status of the error is: Request Filtering: Denied because URL doubled escaping 404.11.  ...

The fix is to run the following from a command prompt on the Exchange server.  This will allow double escaping.

%windir%\system32\inetsrv\appcmd set config "Default Web Site" -section:system.webServer/security/requestfiltering -allowDoubleEscaping:true


(NOTE: I've copied the text from this website: http://blog.customereffective.com/blog/2009/02/crm-40-forward-mailbox-hangs-on-emails-with-and-other-special-characters---exchange-2007-on-server-2008.html)


The error “Request Filtering: Denied because URL doubled escaping 404.11” is NOT logged anywhere in our Exchange Server (neither the event log of the Exchange Server nor the IIS log) so we’re not sure if the issue is related to this fix.


Have any of you had this issue and managed to resolve it? In which log should I find the error “Request Filtering: Denied because URL doubled escaping 404.11” on the Exchange server?


Thanks in advance






Hello all

Could I please ask - how do I go about inserting into a database special characters such as the uppercase O, umlaut 


Please understand that I have been able to insert the special character from inside MMS by putting an N in front of the value

but when I run the  SQL file from inside an ASP.net 4.0 page it comes up as a diamond with a question mark in it

Does anyone have any idea how I would be able to acheive this?


How to write a code to count number of characters/Spaces/numbers/special characters present in a sentence. without use of string function or any predefined functions or MFC/VC++ Classes STL etc use only pure C

sentence ="1. GOD IS GREAT !!!"


Character No.of Characters
A - 1
D - 1
E - 1
G - 2
I - 1
O - 1
R - 1
S - 1
T - 1
Space - 4
! - 3
1 - 1
. - 1
Total literals - 19

Please be sure to have complete working code.

I hope this is the challenging question. If this is not the right form to post it please let me know where to post this type of puzzle questions

Thanks in Advance.
Satish Babu



I'm trying to automate a process wherein an email comes in with a certain Subject, then a regex pulls an email address out of that trigger email, and sends a template to that email address. What I have so far is somewhat mangled. Please help?

Sub CustomMailMessageRule(Item As Outlook.MailItem)
  Dim myolApp As Outlook.Application
  Dim myItem As Outlook.MailItem
  Dim mySend As Outlook.MailItem
  Set myNamespace = myolApp.GetNamespace("MAPI")
  Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
  Set myolApp = CreateObject("Outlook.Application")
  IfNot myFolder.Items = 0 ThenSet myItem = myFolder.Items(1)
   myItem.BodyFormat = olFormatPlain
   Set mySend = myolApp.CreateItemFromTemplate("C:\template.oft")
   With mySend
    .Recipients = RE6(myItem.Body)
    .Subject = "Blahdy blah"EndWith' mySend.SendEndIfEndSubFunction RE6(strData AsString) AsStringDim RE AsObject, REMatches AsObjectSet RE = CreateObject("vbscript.regexp")
  With RE
    .MultiLine = True
    .Global = False
    .IgnoreCase = True
    .Pattern = "(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)" & _
  "|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}"EndWithSet REMatches = RE.Execute(strData)
  RE6 = REMatches(0)

Thank you!


As the title indicates, I have two questions in this question.

1. We used a large lead list (12,000+) leads to send out some marketing material. The configuration was setup to send the email through the email router and replies were directed to a queue. We ended up being black-listed by the Barracuda firewall appliance, even though we followed the guidelines at this site: http://www.ftc.gov/bcp/edu/microsites/spam/index.html

I read somewhere the email router will handle queuing for large quantities of email, but my experience above indicates I was wrong. We will be moving to a emailing provider who integrates with mscrm.

2. Second question. This one is the most important to me. Once we were black-listed the emails started returning to the queue. I pulled a few random bounces from the queue and did an advanced find on leads. I cannot find leads with the matching email address in the bounced email!?!? My question is, how can CRM Send emails to someone we do not have in our system?

Let me know if you need more details, thank you.


Hi All,

Is there a way to show SP libraries incoming email addresses to the organizational address book (in Outlook)?

Thanks a lot



I have a simple email.aspx page that has From:, To:, Subject:, and Body: text boxes. The send button is set to send the email using smtp through System.Net.Mail in ASP.NET 4. 

What I'm really trying to do is set the To: address to automatically retrieve all of the email addresses stored in my SQL database table that my customers entered when they registered for updates from my websites, rather than me type each one in by hand. I am wanting it completely automated without any user interaction.

I have looked everywhere for weeks to try to get help and I can't seem to find anything describing what I am trying to do. I'm really at a loss! Can anyone help me?


I am writing a routine in VBA to read through all the emails in Outlook's Inbox and Outbox that will copy the emails in a pre-selected Sub-Folder into a database and cross-index them by the Sender all the Recipients.

At present I'm having problems with the Address Property of the Recipient Object, in that it simply does not return an email address as the documentation suggests it should.

In researching the problem I came accross Article ID: 282410, which suggestes the case of the problem is that when the emailwas sent, the Address Book Wondow was used to add the Recipient, instead of manually typing the Address and proposes three solutions:

Method 1
Suggests using the Address property of the AddressEntry Object, instread of the Adddress property of the Recipient object. I gave this a go but it returned the same value as the Recipient object itself.

Method 2
Points to Article ID: 196507, which ays that it will work for Exchange, and a Personal Address Book but not Outlook Contact Folders, so I thought there was no point in persuing that either.

Method 3
Is simply impractical for emails that originate from outside an organisation.


I can upload a cut-down version of my code if I could figure out how.

I have a simple workflow attached to a list in WSS 3.0. When an item is created or edited, the workflow waits a specified period of time, then sends an email to three recipients. One recipient is a hard-coded email address, while the other two are SharePoint users. The email is sent correctly to the SharePoint recipients, but not to the hard-coded email address. Also, the hard-coded email address does not appear in the "To" field when received by the SharePoint users. 

I have checked the ULS and event logs and do not find any errors. I have confirmed that the hard-coded address is able to receive email and that the email has not been blocked by our spam filter.

Any idea what would cause this behavior?



I have quite a few posts about the email router/queues/email from CRM so i wanted to start this on a separate thread.

I think I might be missing the point on some things so please bear with me.

I have configured a test email address with an outgoing profile using the email router crm.test@mydomain.com

I have configured a queue that looks at an email address crm.requests@mydomain.com.  Now if i create an email in an account and set it to send from crm.test@mydomain.com and send to crm.requests@mydomain.com and then hit tab to move to the subject the CRM loading circle appears and it resolves the To address as my queue name.  I populate the rest of the email and hit send.

After a short while a look at the queue for crm.request@mydomain.com and the email is there.

My question is should this not also send an actual email to crm.requests@mydomain.com?  if i log into the pop3 account it is not there.

As i mentioned i might be missing the point of queue's in relation to CRM so any help/explaining would be appreciated.

is it possible to have more than 1 email address specified as the incoming email address for a library?


I have the requirment to send an email on create on one of my custom entities. The email To: field is popluated from a contact field in my entity, and the Cc: field should be populated from a varchar field in my entity. Using varchar as an address is however not allowed. I realised that the address fields must be of type contact or account.

Additional addresses should not be created as contacts because they do not fit our business logic.

Is there a way I can allow a custom email address (user inputted) to be used in workflow emails?



I modified the ISV Config file to place a 'Send Email' button on the toolbar of the Opportunity Entity.  The button is working and a new Email is created when clicked, just like on the other Entities, however, the only address that is passed is the Account Name.  I've created 3 additional fields on the opportunity to specify additional email addresses.  Is there a way to also pass these 3 additional addresses to the 'To' field when the Opportunities 'Send Email' button is clicked?



We get an email from one of vendor with subject like "Failure" or "sucess". If it's failure then we have to send the same email with attachement, subject, body and everthing it to the supportcenter and if it's "sucess" create a file with the subject matter in that and dump it on a folder

Can anyone please help me how to acheive this.

Just for testing whether I get the same email to me or not without the condition. I do get it but it's without attachment.

I have one ReceivePort -- POP3 and ReceiveMessage is XMLDocument type and SendMessage type is XMLDocumentType and have send port with Dynamic and I am Contructing this message before sending --

Out=IN;sEMAILTOADDRESS =hjgjhg@jhjd.com;TrustWaveForwardEmailSend(Microsoft.XLANGs.BaseTypes.Address) = @"mailto:" + sEMAILTOADDRESS;

But I am not


Just received an email from this address -> WindowsLiv?e.Hotmail.T?eam@hot-wli?ve-srv92.co?m..is this a spam? Its showing me this


Dear manutd_1989@hotmail.com,

This e-mail has been sent to you by Hotmail to inform you that your account will be deactivated within the next 24 hours due to several unsuccessful login attemps on your account.

To prevent this to happen please login securely to our activation link below:

If you have already confirmed your information then please disregard this message.

WindowsLive Hotmail Team


there is no exchange server in domain. I want use external email(like hotmail.com) for domain user account.

I have install smtp service in MOSS 2010. How to configuration?


thanks a lot.



We have an MSCRM installation at our office as follow:
- A DC with MSCRM (IFD + On Premise mode) and MSCRM Email Router
- A member server with Exchange 2003

We use some workflow that send emails internaly (to some internal address) and this works very fine.

Few days ago, I noticed that emails were not sent / received when sent to an external address (i.e @hotmail.com).

I solved a problem which was that, on the DC event log, I had an error message from MSCRM Email Router component telling me that relay was not allowed on my server. I allowed my DC IP address on the virtual SMTP of my Exchange server.

The message disapeared, and no other error message appears, neither on the DC event log, nor on the Exchange server event log.

But external message won't be distributed!!

On the MSCRM Email Router component, I think everything is well configured. The inbound and outboud access tests are successful, and, again, internal message are OK.

I've tried to send a email directly from the activity page on my web interface. The message seems to be sent because then when I open it, I don't have any  error message saying that the message coyuld not be sent. But it never arrives at destination.

I've obviously tried to send to diffrent external emails (Google, Yahoo, etc.) and checked any spam folder.

Problem remains.

I'm stuck and don't have any idea on how to diagnose further the problem Maybe by tracking sent messages on Exchange?

Because CRM SEEMS to successfully deliver the messages to Exchange (but not sure of this).

Any help or idea would be helpful.




I have created a workflow step which adds an additional email address (a string) to the CC field of a new email entity. The email address is a property retrieved by user input. The workflow step works fine.

I am now amending it to add more than 1 email address to the email. The emails are semicolon delimited and passed as 1 string with same property and separated using Split. However for some reason it is not working. Any idea why please? (Code Below)


 [CrmWorkflowActivity("AdditionalCC", "My Activities")]

	publicpartialclass AdditionalCCActivity: Activity


  protectedoverride ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)



    IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));

    IWorkflowContext workflowContext = contextService.Context;

    ICrmService crmservice = workflowContext.CreateCrmService();


    email emailInstance = new email();

    emailInstance.activityid = new Key(Email.Value);

    List<activityparty> ccreceivers = new List<activityparty>();

    string personreportingfield = this.EMAddress.Trim(';');

    String[] emailaddresses = personreportingfield.Split(';');

    foreach (string emailadd in emailaddresses)


     activityparty toparty = new activityparty();

     toparty.addressused = emailadd;



    emailInstance.cc = ccreceivers.ToArray();


    SendEmailRequest request = new SendEmailRequest();

    request.EmailId = Email.Value;

    request.IssueSend = true;

    request.TrackingToken = "";



    return ActivityExecutionStatus.Closed;




Darren Mercieca



XmlDocument.Load with an XmlDictionaryReader appears to ignore a space immediately following a special character:

const string xml = @"<Colors>Red &amp; Green</Colors>";

var reader = XmlDictionaryReader.CreateTextReader(Encoding.UTF8.GetBytes(xml), new XmlDictionaryReaderQuotas());
var doc = new XmlDocument();


 The result of this code snippet is: <Colors>Red &amp;Green</Colors>. Note that the space after the ampersand has been removed. If I encode the ampersand with &#x26, I get the same result.

Is this a known issue, or am I doing something wrong?




Is there any limitation for the media plan, buy, placement or cost package names on which characters (special characters such as: &, %, etc..) can be introduced into the media plan/buy/placement name field for the Campaign Management API or the Web Console??

I've been told there is a limitation for that field on the Web Console, but I couldn't find any info regarding this through the Help section either.
Where can I find info on this??



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure