Last post Sep 07, 2010 02:54 AM by Wenchao Zeng - MSFT
Sep 03, 2010 10:32 AM|MyronCope|LINK
Using vb.net/asp.net 2005
I am trying to create a string message for an email that I am sending out from my asp.net page like so:
For Each dr In dtDataTable.Rows
strMessage = strMessage & vbCrLf & vbCrLf & Environment.NewLine & dr.Item("UserName") & Environment.NewLine
so I am looping through a datatable and getting each name from each row, that is working well but when I get the email it appears in my inbox with all the names mashed together, you see I am trying both vbcrlf and newline but looks like neither is working
does anyone know what I'm doing wrong?
Sep 03, 2010 11:34 AM|sansan|LINK
If your mail inbox allows html format of the messages, you can send Line Break
Try that and see if it works.
Sep 03, 2010 11:37 AM|MyronCope|LINK
thanks for the feedback.
I am only sending this to myself for testing and trying to avoid using HTML because after testing it will be sent to other people whose servers might filter out HTML emails so I can't really use the <br>
Sep 07, 2010 02:54 AM|Wenchao Zeng - MSFT|LINK
By default, mail body uses HTML as format. I suggest you changing the format of the mail body to text.
If you use System.Net.Mail.MailMessage to generate a mail, please use
MailMessage.IsBodyHtml=false to define the content as plain text.
Otherwise if you use System.Web.Mail. MailMessage, then use MailMessage.BodyFormat=MailFormat.Text to achieve it.
Now, you can use Environment.NewLine to start a new line.