mailmessage -problems with returns not working within body

Joined
Feb 21, 2005
Messages
9
Location
Wisconsin
Programming Experience
10+
I am having a problem with the body of an email accepting returns. This code will launch the default mail application and populate fields automatically. If the body has returns in it, the body in the new mail screen (in outlook in my case) --- shows in one continuous line.

The EmailBody field is populated with the contents of a text box with multiline property set to true. The operator enters the body in the text box returning between paragraphs. When outlook new mail panel is displayed, the whole body is displayed with no returns.

Is there something I need to do to allow for the returns?


VB.NET:
Public Sub setEmailOutgoing(ByVal EmailServer As String, ByVal EmailTo As String, ByVal EmailFrom As String, _
ByVal EmailSubject As String, ByVal EmailBody As String, ByVal SMTPPort As Integer)
 
Dim mm As New MailMessage
Dim smtp As SmtpMail
If Not (EmailServer = "") Then
smtp.SmtpServer = EmailServer
End If
mm.To = EmailTo
mm.From = EmailFrom
mm.Subject = EmailSubject
mm.Body = EmailBody
 
If Not (SMTPPort = 0) Then
mm.Fields.Add("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/URL]", SMTPPort)
End If
 
 
smtp.Send(mm)
 
End Sub
 
I have posted an answer to this question in another forum but I saw it here and thought of something else.

I asked in the other forum whether your TextBox actually had new-line characters in it or whether the text had just wrapped. You may or may not be aware that, even if you set Multiline to True, you still cannot put a new-line character into a TextBox by pressing the ENTER key unless you also set AcceptsReturn to True. If you do not, the form will process the key press instead, which may mean clicking the default button or some other action.

Please check my reply in the other forum also as it includes some questions I would like answered if you can.
 
Back
Top