Link to home
Start Free TrialLog in
Avatar of terrydschmidt
terrydschmidt

asked on

CDO Message - I want to send more than one line in my email message.

I have tried several different ways to send more than just the details of my message.  Below is what I want to do but isn't working.  If I replace all the .TextBody lines with just  .TextBody = Request1.Details.Text  the code works fine.  But the minute I try to get more complicated my .ASP page won't display because there is an error.  How do I get the multiple lines of the TextBody to be displayed in my email?

Set cdoMessage = Server.CreateObject("CDO.Message")
    On Error Resume Next
    With cdoMessage
        Set .Configuration = cdoConfig
        .Fields("urn:schemas:httpmail:importance").Value = 2
        .From = Requests1.EmailAddr.Text
        .To = "terrys@xxxxxx.com"
        .Subject = "New IT Request"
        .TextBody = "Date/Time: " & Request1.ReqDate.Text & Chr(10) & Chr(13)
        .TextBody = .TextBody & "Requestor: " & Request1.Requestor.Text
        .TextBody = .TextBody & "     Phone: " & Request1.Phone.Text & Chr(10) & Chr(13) & chr(10) & chr(13)
        .TextBody = .TextBody & "Priority: " ReqPriority
        .TextBody = .TextBody & "     Request Type: " & Request1.ReqType.Text
        .TextBody = .TextBody & "     Category: " & Request1.Category.Text & Chr(10) & Chr(13) & chr(10) & chr(13)
        .TextBody = .TextBody & Request1.Details.Text

        .Send
    End With
    Set cdoMessage = Nothing
    Set cdoConfig = Nothing
    On Error Goto 0
Avatar of g_johnson
g_johnson
Flag of United States of America image

what is the error?

try building textBody in a string

strText = this & chr(10) & chr(13) & that etc ...

.textbody = strText
Avatar of terrydschmidt
terrydschmidt

ASKER

I just tried this   .TextBody = "Test:" & Request1.Details.Text    and I get a blank message but NO error.  
This is in an .asp file on my webpage.
So, I tried .TextBody = "Test:"  and that works.  Test: shows in my email message.

I tried:
Dim txtBody

txtBody = "Test"

.txtBody = txtBody

I got Test in my email message but if I did:  .txtBody = txtBody & Request1.Details.Text  I got a blank message.  It seems like an & is not working.  My visual basic is rusty how do I create a string without ampersans?
OK, ampersan is not the problem it's when I combine quoted text and a variable.

txtBody = "Hi there" & vbNewLine & vbNewLine & _
        "This is line 1" & vbNewLine & _
        "This is line 2" & vbNewLine & _
        "This is line 3" & vbNewLine & _
        "This is line 4"

above works - my email message shows all the text.

txtBody = "Hi there" & vbNewLine & vbNewLine & _
        "This is line 1" & vbNewLine & _
        "This is line 2" & vbNewLine & _
        "This is line 3" & vbNewLine & _
        "This is line 4" & Request1.Details.Text

above does not work.  I get a blank email message.
you're in uncharted territory for me, but what about something like

strHold = request1.details.text

txtbody = ... & vbNewLine & "This is line 4" & strHold

I think I found my error. Request1.Details.Text is suppose to be Requests1.Details.Text  (see the s between the t and the 1 it helps when it there).  I now broke my send so I am not getting any emails to test.  I get back to you when I figure what I broke.

I answered my own question above.  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial