Results 1 to 2 of 2

Thread: mailmessage - problem handling returns in body

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Location
    Wisconsin
    Posts
    4

    Question mailmessage - problem handling returns in body

    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 Code:
    1. 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)
    2.  
    3.         Dim mm As New MailMessage
    4.         Dim smtp As SmtpMail
    5.         If Not (EmailServer = "") Then
    6.             smtp.SmtpServer = EmailServer
    7.         End If
    8.         mm.To = EmailTo
    9.         mm.From = EmailFrom
    10.         mm.Subject = EmailSubject
    11.         mm.Body = EmailBody
    12.  
    13.         If Not (SMTPPort = 0) Then
    14.             mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", SMTPPort)
    15.         End If
    16.  
    17.  
    18.         smtp.Send(mm)
    19.  
    20.     End Sub

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: mailmessage - problem handling returns in body

    I have reproduced your code and tested it.

    First of all, what does mm.Fields.Add do? I know that it adds an entry into the IDictionary, but the help topic for MailMessage.Fields is incomplete in both VS and on MSDN.

    Secondly, does your code really open the default e-mail client? I would love to be able to reproduce that behaviour but when I use it your code simply sends the message off itself. I thought that that was all you could do with the System.Web.Mail classes.

    Thirdly, if I use a body with new-line characters in it, the e-mail message reproduces those characters faithfully when I receive it again. Are you sure your body has new-lines and is not just wrapped in the text box?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width