ARTICLE AD BOX
I have an HTML file which has some style. If loaded in browser, e.g. Edge, it looks OK.
Now I want to send the rendered HTML as an email using Gmail. What I will do is:
Copy the rendered page from Edge; Paste into Gmail, which looks ok; Send.The email is received, and it looks OK.
How can I send the rendered HTML using Gmail using C# code?
We can use SmtpClient to send HTML string:
var message = new MailMessage(from, to) { Subject = "Test Subject", Body = html, IsBodyHtml = true }; var smtp = new SmtpClient("smtp.gmail.com", 587) { EnableSsl = true, Credentials = new NetworkCredential(from, appPassword) };If send the original HTML content, it will have the style, and when received, it will mess up.
