Help with "& vbcrlf" in Emails Sent as Text Using ASP



  • Dear Daily WTF,

    I've got an ASP file that sends an email out as text.

    Here's the problem...The body of the email begins with 2 blank lines at the top and ends with 2 blank lines at the very bottom. When the email is opened (Eudora 7.1) the 2 blank lines (Carriage Returns) at the top and bottom are stripped completely out. What is going on? Is it my code or is it possibly the email program itself?


    ASP Code looks like this:

    Dim EmailBody
    EmailBody = vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Dear Friend," & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "How are you! I will call you later." & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Have a Great Day!" & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Sincerely," & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Your Friend" & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & vbcrlf

    (And I use the sendmail function, set up for text, to send the email body above)

    I've tried:

    EmailBody = EmailBody & vbcrlf & vbcrlf & vbcrlf & vbcrlf

    and

    EmailBody = EmailBody & "   " & vbcrlf

    EmailBody = EmailBody & "   " & vbcrlf

    and

    EmailBody = EmailBody & " " & vbcrlf (Yes, a WTF...but WTH)

    No Help...body of email when received never has over one carriage return (blank line) in it, and it seems that I'm not allowed any blank line at all at the beginning or at the end of the email body. It's as if the email body gets trimmed of & vbcrlf . Any ideas? Is it possible to put a blank text character within the quotes, like an ALT-255? (Yes, I know...WTF!...longsas story)

    Any help would be greatly appreciated.
    Thanks

     



  • It could be the email program stripping it out (I know Microsoft Outlook seems to strip newline characters sometimes). Perhaps try sending the exact same email yourself via an email application, and see if they still get stripped?
    View the source of the message (could be called "View Source", "Show Original", or something else in your email client) and see if your newlines are still there, or if they were actually stripped out of the email.



  • Here is the code snippet I found...

    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
    message.To.Add("luckyperson@online.microsoft.com");
    message.Subject = "This is the Subject line";
    message.From = new System.Net.Mail.MailAddress("From@online.microsoft.com");
    message.Body = "This is the message body";
    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
    smtp.Send(message);



  •  

    Instead of vbcrlf, try ENVIRONMENT.NEWLINE 

    @Caution-MyCode_LooksAndActsLike_PeeWeeHerman said:

    Dear Daily WTF,

    I've got an ASP file that sends an email out as text.

    Here's the problem...The body of the email begins with 2 blank lines at the top and ends with 2 blank lines at the very bottom. When the email is opened (Eudora 7.1) the 2 blank lines (Carriage Returns) at the top and bottom are stripped completely out. What is going on? Is it my code or is it possibly the email program itself?


    ASP Code looks like this:

    Dim EmailBody
    EmailBody = vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Dear Friend," & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "How are you! I will call you later." & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Have a Great Day!" & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Sincerely," & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & "Your Friend" & vbcrlf
    EmailBody = EmailBody & vbcrlf
    EmailBody = EmailBody & vbcrlf

    (And I use the sendmail function, set up for text, to send the email body above)

    I've tried:

    EmailBody = EmailBody & vbcrlf & vbcrlf & vbcrlf & vbcrlf

    and

    EmailBody = EmailBody & "   " & vbcrlf

    EmailBody = EmailBody & "   " & vbcrlf

    and

    EmailBody = EmailBody & " " & vbcrlf (Yes, a WTF...but WTH)

    No Help...body of email when received never has over one carriage return (blank line) in it, and it seems that I'm not allowed any blank line at all at the beginning or at the end of the email body. It's as if the email body gets trimmed of & vbcrlf . Any ideas? Is it possible to put a blank text character within the quotes, like an ALT-255? (Yes, I know...WTF!...longsas story)

    Any help would be greatly appreciated.
    Thanks

     



  • @Medezark said:

    Instead of vbcrlf, try ENVIRONMENT.NEWLINE

    Given that it's ASP, it's going to be vbCrLf already. And, that's the correct sequence for email anyway.

    <guess type="wild">Perhaps sticking a plain chr(10) or chr(13) at the beginning would work?</guess>



  • @pkmnfrk said:

    @Medezark said:

    Instead of vbcrlf, try ENVIRONMENT.NEWLINE

    Given that it's ASP, it's going to be vbCrLf already. And, that's the correct sequence for email anyway.

    <guess type="wild">Perhaps sticking a plain chr(10) or chr(13) at the beginning would work?</guess>

    On further reflection, I think your mail client is stripping out leading and trailing whitespace.


Log in to reply