I am trying to send an HTML email though C# code. Everything works fine. I can send the email with a logo and icons. The only issue, I am facing is that formatting of the Header is lost when I send the email to Outlook. Below is my code:
This is how the screen looks like on HTML page:
when I send the email to Outlook then the screen looks like this:
Both the company name and city name moves underneath the icon. I tried changing the flex Direction to Row, but that did not fix anything. I also tried outlook zoom setting and it is set to 100%. This is the C# code to send the email:
Any help why the formatting of the header is lost in HTML will be highly appreciated.
HTML
<div class="container">
<div class="logo">
<img src="Images/delete.png" alt="RAC" width="80" height="80" />
</div>
<div class="names">
<div class="name1">This is City Name</div>
<div class="name2">This is company Name</div>
</div>
</div>
I am developing this in ASP.net web forms.
This is the style sheet:
CSS
.container { display: flex; align-items: center; padding: 10px; background-color: #335970; width: 100%; }
.logo { margin-right: 10px; }
.names { display: flex; flex-direction: column; }
.name1 { font-size: 25px; color: #e9c46a; }
.name2 { font-size: 25px; color: white; }
Code
C#
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("test", EmailPass);
client.Port = 200;
client.EnableSsl = true;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mail = new MailMessage();
mail.IsBodyHtml = true;
mail.From = test;
mail.To.Add(new MailAddress("t@t.com"));
mail.Subject = "test";
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
{
body = reader.ReadToEnd();
}
mail.Body = body;
client.Send(mail);