I am trying to make new Lines using a Web service (SOAP in asmx) Rather than have it send the Email with new Lines using "\n", it just shows a straight Line.
My code looks like this :
[WebMethod]
public bool SendCashBagSerial(string email, string fullname, string SerialNumCode, string purpleworksemail)
{
string to = email; //To address
string from = purpleworksemail;
MailMessage message = new MailMessage(from, to);
string EmailBody = "Dear "+ fullname +"\n Your CashBag Serial is : "+ SerialNumCode + "\n Please Quote this Number to Complete your Request. \n Regards, \n Purpleworks \n ";
message.Subject = "Your Cash Bag Serial!";
message.Body = EmailBody;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.office365.com", 587);
System.Net.NetworkCredential basicCredential1 = new System.Net.NetworkCredential("*******@*************", "*******");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
try
{
client.Send(message);
}
catch(Exception ex)
{
throw ex;
}
return true;
}
Is there something I am not doing correctly?
Line breaks are often 2 characters, a line feed and a carriage return. To replicate this you do \r\n
... but your email is html
message.IsBodyHtml = true;
So you need to use <br>