I am sending a mail using C# using the SmtpClient
class. I am doing the following things before sending the mail.
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 the mail, the mail gets sent, here is what I get as the content of the mail in outlook when I press the view source. Below is the content of the email with view source (Obviously I have kept only a 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 this appears broken(the images) in the mail, but when I copy this source and paste it into an editor and open the file using a browser all seems good (even the images).
Update : Added image of the mail from outlook
Any ideas ????
AlternateView
? – RufescentAlteranteView
will try it out and if it works will post an answer here – Westernism