Issue with %CRLF%??

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
jonesey10
Newbie
Posts: 8
Joined: Wed Mar 31, 2010 3:11 pm

Issue with %CRLF%??

Post by jonesey10 » Wed Mar 31, 2010 3:15 pm

I'm fairly new and I'm having issues emailing/reading lines from a text. It seems to have something to do with the CRLF command because when I take it out of the code the email works and has the data, but I need the lines to be on separate lines. Any help would be greatly appreciated!

VBStart
Function CreateEmail(strRecipient, strSubject, strBody)
'Create OL App object
Set objOLApp = CreateObject("Outlook.Application")

If objOLApp is nothing then
MsgBox "Could not create OL App. Shutting Down"
Exit Function
End If

'Create a new mail item
Set objMsg = objOLApp.CreateItem(0)
If objMsg is nothing then
MsgBox "Could not create Mail Item. Shutting Down"
Exit Function
End If

'Set basic message parameters
objMsg.To = strRecipient
objMsg.Subject = strSubject
objMsg.Body = strBody

'Send the message
objMsg.Send

'Free up the space
Set objOLApp = Nothing
Set objMsg = Nothing

CreateEmail = "Success"
End Function
VBEnd

Let>strTo=[email protected]
Let>strSubj=Daily Sales
Let>body=
Let>k=1
Label>start
ReadLn>c:\misc.txt
If>line=##EOF##,finish
Let>body=%body%%CRLF%line%
Let>k=k+1
Goto>start
Label>finish

VBEval>CreateEmail("%strTo%","%strSubj%","%body%"),Answer

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 31, 2010 3:37 pm

VBScript doesn't like physical breaks. You can do this to replace them with VBScript's vbCRLF variable

StringReplace>body,CRLF," & vbCRLF & ",body
VBEval>CreateEmail("%strTo%","%strSubj%","%body%"),Answer
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

jonesey10
Newbie
Posts: 8
Joined: Wed Mar 31, 2010 3:11 pm

Post by jonesey10 » Wed Mar 31, 2010 4:54 pm

Thanks so much for your quick response.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Mar 31, 2010 6:29 pm

Hi jonesey10,

This may or may not help but I'll mention it anyway. I noticed near the end of your posted code above, you have this line:
  • Let>body=%body%%CRLF%line%
To me, it looks like you really should have this (looks like a % was missing):
  • Let>body=%body%%CRLF%%line%
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts