|
-
Jan 23rd, 2011, 08:18 AM
#7
Thread Starter
PowerPoster
Re: vbcrlf and vbnewline problem
Yep, that fixed it. Thanks! I checked out my code and I didn't put in .IsBodyHtml but i have now and I put it as html. Everything is formatted correctly now.
 Originally Posted by kevininstructor
Sounds like you are doing HTML body for your email message which means </br> will be your line break
So something like this would fix your line break issue. The following can not be used by copy/paste as it has variables that you do not have.
Code:
Sub SendMessage()
Try
Using TheMessage As New System.Net.Mail.MailMessage()
TheMessage.From = New System.Net.Mail.MailAddress(FromAddress)
TheMessage.To.Add(New System.Net.Mail.MailAddress(SendToAddress))
TheMessage.Subject = ApplicationName
TheMessage.Body = String.Format( _
"This is an automated email, please do not respond<br><br>An " & _
"exception ocurred in <br><span style=""font-weight: bold; padding-left:20px;" & _
"padding-right:5px"">Application name</span>{0}<br>" & _
"<span style=""font-weight: bold; padding-left: 5px;padding-right:5px"">" & _
"Application Version</span>{1}<br><span style=""font-weight: bold; " & _
"padding-left: 70px;padding-right:5px"">Exception</span>{2}", _
ApplicationName, ApplicationVersion, ErrorMessage)
TheMessage.IsBodyHtml = True
Dim MailClient As New System.Net.Mail.SmtpClient(SmtpClient)
MailClient.UseDefaultCredentials = True
MailClient.Send(TheMessage)
End Using
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|