1

I have a html template that works when it is as is and sent to my Gmail. The css works and the positioning of elements is fine.

However, I when I load it into my application and do a replace string of certain text and resend it from my application, I noticed that in Gmail, not only is the css gone but all positioning is messed up.

This is my html email as is without replacing the text:

http://s000.tinyupload.com/?file_id=00874388724644178645

This is how I load the html and replace the text:

HtmlDocument document = new HtmlDocument();
document.Load(@message.Location);
content = document.DocumentNode.OuterHtml;
content = content.Replace("##" + innerItem + "##", line);
var eContent = new HtmlString(content);

I then proceed to sent the eContent string to my email via another function.

This is my html email after I replaced the text:

http://s000.tinyupload.com/?file_id=03908737686605061545

I am unsure of how else I can handle this email template properly.

I'm using the HTML Agility Pack to read the document in also.

EDIT:

The replaced email works with other email providers like the CPanel one but not Gmail

JianYA
  • 2,750
  • 8
  • 60
  • 136

1 Answers1

0

This might happen if you have any character Gmail doesn't support in styles (may it be inline or in tags). This can include characters like =,*,/,$,%,`, &, @, ^, {, }, [, ], (, ), ?, |, <, > more about that. Feel free to post your code for further help.

Power Mouse
  • 727
  • 6
  • 16
  • I've posted the before and after code in my question. You can download those files. – JianYA Jul 16 '19 at 14:19
  • @JianYA, sorry i cant access to that links. also, check link provided. – Power Mouse Jul 16 '19 at 15:53
  • Sorry, the link works for me? Its a public filesharing site. do you have any other option to upload my files? – JianYA Jul 16 '19 at 15:55
  • check this link, it might resole your mistery: [https://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail](https://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail) – Power Mouse Jul 16 '19 at 19:47
  • I'm using MailKit in .net core to send. – JianYA Jul 17 '19 at 00:53