Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailMessage is adding two dots for one dot when email is opened in Outlook or other clients

Tags:

c#

email

outlook

I am generating and sending email using C#.

The mail message is html formatted, and everything appears fine just before the Send method is called i.e. there is only a single dot just before aspx in the href URL, but when I open the sent email in Outlook or any other email client, it shows a double dot for a href as in code below.

<a href='http://localhost/xyz/invitation..aspx?invitecode=92EFB482-1792-4BC6-9507-70D2E3F06FE0'>Click Here </a>

My question: Why would this be happening, and is there any way to resolve this problem like some special encoding for MailMessage.BodyEncoding ? I am using the default encoding (ASCII) for MailMessage.BodyEncoding.

like image 526
Sunil Avatar asked Sep 22 '14 16:09

Sunil


People also ask

What is Dot stuffing?

Whenever the SMTP client sees a line that begins with a period, it has to add another one. And whenever the SMTP server sees a line that begins with a period, it has to remove it. This is called “dot-stuffing”. If an email has the line “.”, it'll be sent on the wire as “..”.

What are two dots in URL called?

Relative path and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

Do dots matter in Outlook?

DOTS MATTER IN: Microsoft Outlook, Yahoo Mail, Apple iCloud ID. DOTS DON'T MATTER IN: Gmail, Facebook ID. DOTS STRICTLY PROHIBITED: Twitter.

Why does my email look like Code outlook?

Why is my email strangely formatted, with lines of code? It usually means because you are trying to open your email with another email client than the web version of Gmail, such as Apple Mail, Outlook or Google Inbox. Or it can also happen because you copied/pasted your email from another tool like Word or Google Docs.


1 Answers

Try using UTF8 encoding. This should work

mail.BodyEncoding = System.Text.Encoding.UTF8;
like image 62
NMK Avatar answered Sep 16 '22 14:09

NMK