I can use this code to send an email on my Exchange server
Try
Dim SmtpServer As New SmtpClient
Dim mail As New MailMessage
SmtpServer.Credentials = New Net.NetworkCredential()
SmtpServer.Port = 25
SmtpServer.Host = "email.host.com"
mail = New MailMessage
mail.From = New MailAddress("myemail@email.com")
mail.To.Add("otheremail@email.com")
mail.Subject = "Equipment Request"
mail.Body = "This is for testing SMTP mail from me"
SmtpServer.Send(mail)
catch ex As Exception
MsgBox(ex.ToString)
End Try
But how can I add multiple lines to the body?
I would create a variable for your body and then add that to the mail.Body so it would look something like this.
That will append the line breaks and you should have each line on it's own in the email.
Just treat it like a normal text object where you can use
Environment.NewLine
orvbNewLine
between sentences.StringBuilder
is useful here:Like this?
then
If the body of your message needs to be in HTML format, add the
<br>
tags right in your String.vbCrLf
andStringBuilder
don't work if the body is in HTML format.If it is not in HTML format, the other answers here appear to be good.
try the
system.environment.newline
in the the string ... should work