I am sending mail using C # using the SmtpClient class. Before sending mail, I do the following.
var mailMessage = new MailMessage(); model.ToAddresses.ForEach(to => mailMessage.To.Add(to)); mailMessage.Subject = "Test Email - By Yasser"; mailMessage.Body = String.Format("{0}{1}{2}", "<html><body>", GetEmailContent(model), "</body></html>"); mailMessage.IsBodyHtml = true; return MailService.SendEmail(mailMessage);
and below is my MailService class:
public class MailService { public static bool SendEmail(MailMessage mailMessage) { var smtpClient = new SmtpClient(); try { smtpClient.Send(mailMessage); return true; } catch(Exception exp) { return false; } } }
Now, when I send mail, the mail is sent, thatβs what I get as the contents of the mail in Outlook when I click the view source. Below is the content of the email with the view source (obviously, I saved only part of the image data)
<html> <body> <h1>Test</h1> <h2>Hello World</h2> <h3>Missing close h3 tag</h3> <p> <a href="www.google.com"> <img src="data:image/gif;base64,/9j/4AAQSkZJRgABAgEAYABgAAD/4Q8HRXhpZgAAT" /> </a> </p> </body> </html>
So it looks broken (images) in the mail, but when I copy this source and paste it into the editor and open the file with a browser, everything seems good (even the images).
Update: added image mail from Outlook

Any ideas ????
source share