I have created a method that will send an email with information to customers. However, the email looks awful cus there is no style to it. I can't apply the style to the email for some reason. I have tried to google it, and there is a lot on how to solve this in code behind, but that's not my issue. I must place the css code in the Html body, since it must be displayed for the client when he opens the email.
So my question is, how do I add css to the html code above? I have tried doing:
<div style='...'></div>
and this does not work
Any help on how to solve this is appreciated. Below some of my code. I have shortened it, for readability.
string HtmlBody = @"<div style='float: right'>
<h3>Faktura</h3> <br />
Navn:<asp:Label ID='navn' runat='server' Text='%Navn%'/> <br />
Adresse:<asp:Label ID='adresse' runat='server' Text='%Adresse%'/> <br />
Postnr:<asp:Label ID='postnummer' runat='server' Text='%Postnr%'/> <br />
Land:<asp:Label ID='land' runat='server' Text='Danmark' /> <br />
Tlf: <asp:Label ID='tlfnummer' runat='server' Text='%Tlf%' /> <br />
Mail: <asp:Label ID='email' runat='server' Text='%Email%' /> <br />
<div style='float: right'>
<p>Dato</p>
</div>
<hr /> <br />
<table style='background-color: #c00764'>
<tr>
<td><b>Fakturanr:</b></td>
<td>%fakturanr%</td>
</tr>
<tr>
<td><b>Ordrenr:</b></td>
<td>%Ordrenr%</td>
</tr>
</table>
</div>";
Here are some of my info on the mail part
MailMessage mailMsg = new MailMessage();
mailMsg.IsBodyHtml = true;
mailMsg.Priority = MailPriority.Normal;
var smtpValues = GetSmtpValues();
var smtpCredentials = GetNetworkCredentials();
SmtpClient smptClient = new SmtpClient(smtpValues.Key, smtpValues.Value);
smptClient.EnableSsl = true;
smptClient.Credentials = new NetworkCredential(smtpCredentials.Key, smtpCredentials.Value);
//Send mail
smptClient.Send(mailMsg);
IsBodyHtmlas true for yourSystem.Net.Mail.MailMessageobject?