Reputation: 1868
I have tried multiple variations of the following code, but I still get the same result. I am trying to have the last line "Issue Description: ...." to appear on a new line.
I have tried vbCrLf, vbCr, and & Environment.NewLine & _ None of which work.
Does anyone else have any suggestions?
Just a note: The other emails are properly formatted. Also, if I add put 2 vbCr (s) at the end of the 'Issue Title' line then it looks normal.
This one in particular seems to be a thorn in my side.
The result:
The code:
Dim mail As New MailMessage()
Dim strbody As String
strbody = Nothing
'set the addresses
mail.From = New MailAddress("[email protected]")
mail.[To].Add(Email_Add)
'set the content
mail.Subject = Issue_Num & " Issue has been created."
strbody = "Your issue has been created." & vbCr & vbCr
strbody += "The Issue Team has received the following issue: " & vbCrLf
strbody += "Issue ID: " & Issue_Num & vbCrLf
strbody += "Issue Title: " & Email_Summary & vbLf
strbody += "Issue Description: " & Description & vbCrLf
mail.Body = strbody
'set the server
Dim smtp As New SmtpClient("mailhost.mailserver.com", 15)
'send the message
smtp.Send(mail)
When I use the following code:
'set the content
mail.Subject = Issue_Num & " Issue has been created."
strbody = "Your issue has been created." & vbCrLf & vbCrLf
strbody += "The Issue Team has received the following issue: " & vbCrLf
strbody += "Issue ID: " & Issue_Num & vbCrLf
strbody += "Issue Title: " & Email_Summary & vbCrLf & vbCrLf
strbody += "Issue Description: " & Description & vbCrLf
I get this:
Upvotes: 1
Views: 5643
Reputation: 39
Message.to.Add(ToEmail)
Message.From = New MailAddress(FromEmail)
Message.Attachment.Add(Attachment)
Dim body As String = "Hello user" + ","
body += "<br /><br />"
body += tbEmailBody.Text.Replace(vbCrLf, "<br />")
'This line and the "Message.IsBodyHtml = True" are the important lines to get it to work.
body += "<br /><br />"
body += "<br /><br />Thanks"
Message.Body = body
Message.IsBodyHtml = True
I didn't see this exact answer but maybe I overlooked it. Maybe someone else will find it useful Good luck.
Upvotes: 0
Reputation: 1
dim str as string
put html code as string like this-
str = "<table> <tr> <td> Name : </td> <td> Yuwraj D. Bramhankar </td></tr><tr> <td> Address : </td> <td> 439, Anand Nagar, Nagpur 09 - INDIA</td></tr> </table>"
mail.Body = str
Dim smtp As New SmtpClient("mailhost.mailserver.com", 15)
'send the message here
smtp.Send(mail)
Upvotes: -1
Reputation: 10374
Make the mail format into HTML like this:
mail.IsBodyHtml = True
And then add an html break tag (<br />
) where you want a line break.
Upvotes: 6