If create the body property as
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.Body ="First Line \n second line";
I also tried
message.Body ="First Line" + system.environment + "second line";
Both of these were ignored when I received the message (using outlook).
Any ideas on how to get mutliple lines? I am trying to avoid html encoding so that the email will play nicer with spam filters.
thanks
As per the comment by drris, if IsBodyHtml
is set to true then a standard newline could potentially be ignored by design, I know you mention avoiding HTML but try using <br />
instead, even if just to see if this 'solves' the problem - then you can rule out by what you know:
var message = new System.Net.Mail.MailMessage(); message.Body = "First Line <br /> second line";
You may also just try setting IsBodyHtml
to false
and determining if newlines work in that instance, although, unless you set it to true
explicitly I'm pretty sure it defaults to false
anyway.
Also as a side note, avoiding HTML in emails is not necessarily any aid in getting the message through spam filters, AFAIK - if anything, the most you do by this is ensure cross-mail-client compatibility in terms of layout. To 'play nice' with spam filters, a number of other things ought to be taken into account; even so much as the subject and content of the mail, who the mail is sent from and where and do they match et cetera. An email simply won't be discriminated against because it is marked up with HTML.
In case you dont need the message body in html, turn it off:
message.IsBodyHtml = false;
then use e.g:
message.Body = "First line" + Environment.NewLine + "Second line";
but if you need to have it in html for some reason, use the html-tag:
message.Body = "First line <br /> Second line";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With