• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

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
0
terrydschmidt
Asked:
terrydschmidt
  • 4
  • 2
1 Solution
 
g_johnsonCommented:
what is the error?

try building textBody in a string

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

.textbody = strText
0
 
terrydschmidtAuthor Commented:
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?
0
 
terrydschmidtAuthor Commented:
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
g_johnsonCommented:
you're in uncharted territory for me, but what about something like

strHold = request1.details.text

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

0
 
terrydschmidtAuthor Commented:
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.

0
 
terrydschmidtAuthor Commented:
I answered my own question above.  Thanks!
0
 
GranModCommented:
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now