Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Carriage return into CDOSYS message body

Status
Not open for further replies.

Steel811

Programmer
Jan 2, 2008
26
0
0
US
Hello,

I have a feeling this is a very simple issue.

I am trying to insert a bunch of carriage returns into the textbody of my CDOSYS email that I am generating in one of my vbscripts. The CDOSYS line that I have is this:

objEmail.Textbody = "Here are the Results of the daily download. &<BR>&<BR>AAA: " &AAAflag& "&<BR>AAA_MOD: " &AAAmodflag& "&<BR>ASPPA: " &ASPPAflag& "&<BR>CAS: " &CASflag& "&<BR>CCA: " &CCAflag& "&<BR>CIA: " &CIAflag& "&<BR>JBEA: " &JBEAflag

Which obviously doesn't work, as I would like it to print out like this in the actual email:

AAA: <TEXT>
AAA_MOD: <TEXT>
ASPPA: <TEXT>
CAS: <TEXT>
CCA: <TEXT>
CIA: <TEXT>
JBEA: <TEXT>

I think I'm sorta on the right track, but I'm not quite there. Any help is greatly appreciated!

Thanks,
Sheel
 
Here is a snippet from one of my applications that works just fine.

Code:
    SendEmail "Job# " & txtJobNum.Text & " - " & txtJobName.Text, _
    cboProgrammer.Text & "@xxxx.com", IMBSeqNumGenEmailAddr, AddCRLF("Job ID: " & JobID) & _
    AddCRLF("Job#: " & txtJobNum.Text) & _
    AddCRLF("Job Name: " & txtJobName.Text) & _
    AddCRLF(BoldText("Job Quantity: " & txtJobQty.Text)) & _
    AddCRLF(BoldText("Starting Sequence#: " & txtStartSeq.Text)) & _
    AddCRLF(BoldText("Ending Sequence#: " & txtEndSeq.Text)) & _
    AddCRLF("Programmer: " & cboProgrammer.Text) & _
    "Mail Date: " & dtMailDate.Value

Public Sub SendEmail(strSubject As String, _
                      strRecipient As String, _
                      strSender As String, _
                      strBodyText As String)
    Dim lobj_cdomsg As CDO.Message
    Set lobj_cdomsg = New CDO.Message
    lobj_cdomsg.Configuration.Fields(cdoSMTPServer) = "Imail.xxxx.com"
    lobj_cdomsg.Configuration.Fields(cdoSMTPServerPort) = 25
    lobj_cdomsg.Configuration.Fields(cdoSMTPConnectionTimeout) = 30
    lobj_cdomsg.Configuration.Fields(cdoSendUsingMethod) = cdoSendUsingPort
    lobj_cdomsg.Configuration.Fields.Update
    lobj_cdomsg.To = strRecipient
    lobj_cdomsg.From = strSender
    lobj_cdomsg.Subject = strSubject
    lobj_cdomsg.HTMLBody = strBodyText
    lobj_cdomsg.Send
    Set lobj_cdomsg = Nothing
End Sub

Public Function AddCRLF(InputStr As String) As String
    AddCRLF = Trim$(InputStr) & "<br>"
End Function

Public Function BoldText(UnBoldStr As String) As String
    BoldText = "<b>" & UnBoldStr & "</b>"
End Function

Swi
 
See my sub for sending emails:

lobj_cdomsg.HTMLBody = strBodyText

Swi
 
I would also suggest breaking the text into lines so you can read it more clearly:

Code:
objEmail.HTMLBody = "Here are the Results of the daily download.<BR>" & _
"AAA: " & AAAflag & "<BR>" & _
"AAA_MOD: " & AAAmodflag & "<BR>" & _
"ASPPA: " & ASPPAflag & "<BR>" & _
"CAS: " & CASflag & "<BR>" & _
"CCA: " & CCAflag & "<BR>" & _
"CIA: " & CIAflag & "<BR>" & _
"JBEA: " & JBEAflag

Swi
 
Thanks Swi. I ended up finding the HTMLBody option in CDOSYS as well and used that. It now works perfectly!

Thanks again!
Sheel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top