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.
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 “..”.
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.
DOTS MATTER IN: Microsoft Outlook, Yahoo Mail, Apple iCloud ID. DOTS DON'T MATTER IN: Gmail, Facebook ID. DOTS STRICTLY PROHIBITED: Twitter.
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.
Try using UTF8 encoding. This should work
mail.BodyEncoding = System.Text.Encoding.UTF8;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With