Outlook: Backslash in email body garbles text

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Michel
Newbie
Posts: 17
Joined: Fri May 20, 2011 2:12 pm
Location: Ottawa

Outlook: Backslash in email body garbles text

Post by Michel » Mon Jul 11, 2011 3:13 pm

G'day

I'm sending an email to clients via outlook where in the body of the email the following would be common text:

---------------------------------------------

Hello,

You can find a copy of your report:
\\Server_name\METRIC SYSTEM\Reports\Customer Experience \HRSC\Weekly Report

Thank you.

--------------------------------------------

However - the backslashs makes the text come out like this

---------------------------------------------

Hello,

You can find a copy of your report:
\ SYSTEM Experience Report

Thank you.

--------------------------------------------

.. basically only print out words where there is a SPACE before the word.


I tried escape characters: double-quotes, single quotes, even adding a SPACE in front of every word - but to no avail.

Code is as follows

Code: Select all

VBSTART


Dim objMsg, objOLApp

Function CreateEmail(strRecipient,strbccRecipient, 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
  'Need blind copy: objMessage.Bcc = "[email protected]"
  objMsg.To = strRecipient
  objMsg.bcc = strbccRecipient
  objMsg.Subject = strSubject
  objMsg.Body = strBody

  CreateEmail = "Success"
End Function

Sub AddAttachment(strAttachment)
    objMsg.Attachments.Add(strAttachment)
End Sub

Sub SendMessage
    objMsg.Send
End Sub

Sub CleanUp
  'Free up the space
  Set objOLApp = Nothing
  Set objMsg = Nothing
End Sub


VBEND


// Define current location
ChangeDirectory>..
let>Root_path=%CWD%
let>Calculation_folder=%Root_path%\Calculations
let>Previous_folder=%Root_path%\Previous
let>Current_folder=%Root_path%\Current
let>Scheduler_folder=%Root_path%\Scheduler
let>Email_folder=%Root_path%\Email
let>Email_attachment_folder=%Email_folder%\Attachments
Let>PDF_folder=C:\Documents and Settings\usr.CBC-F00874BFBC5\My Documents\SSC-CSP\Reports\Print_to_PDF
Day>the_day
Month>the_month
Year>the_year


//Get list of people to send email to
let>strTo=
let>Row=1
Label>READFILE
readln>%Email_folder%\Email_To_List.txt,%Row%,TextLine
If>TextLine=##EOF##
goto>EndLoop
endif>
let>strTo=%TextLine%;%strTo%
let>Row=%Row%+1
goto>READFILE
Label>EndLoop

// Always bcc [email protected]
Let>[email protected]

// Get Subject line.
ReadFile>%Email_folder%\Email_Subject.txt,strSubj
let>strSubj= %strSubj%   ( %the_year% %the_month% %the_day% )
// VBScript doesn't like double quotes ("). Escape character is to double - double quotes ("")
StringReplace>strSubj,","",strSubj

// Get Body.
ReadFile>%Email_folder%\Email_Body.txt,strBody
// VBScript doesn't like double quotes ("). Escape character is to double - double quotes ("")
StringReplace>strBody,","",strBody
// VBScript doesn't like physical breaks. Replace them with VBScript's vbCRLF variable
StringReplace>strBody,CRLF," & vbCRLF & ",strBody

// Create email
VBEval>CreateEmail("%strTo%","%strbccRecipient%","%strSubj%","%strBody%"),Answer
If>Answer=Success

// Start with BLANK list
let>File_name=

// Read line by line list of files to send. Loop end when reach end of Email_files_to_send.txt file
let>Row=1
Label>READ_Email_files_to_send
readln>%Email_folder%\Email_files_to_send.txt,%Row%,File
If>File=##EOF##
goto>EndLoop_Email_files_to_send
endif>

// No longer BLANK list. Got a file
let>File_name=%File%

// All files sent of from lastest "Previous" folder
// Add in lastes date into file name
StringReplace>File_name,.,_%the_year%_%the_month%_%the_day%.,File_name

// Make sure file exisits
IfFileExists>%Previous_folder%\%the_year%_%the_month%_%the_day%\%File_name%
// Add file from the lastest "Previous" folder 
VBRun>AddAttachment,%Previous_folder%\%the_year%_%the_month%_%the_day%\%File_name%
Endif

// Let see if there are more files to add.
let>Row=%Row%+1
goto>READ_Email_files_to_send
Label>EndLoop_Email_files_to_send

//Send it-!
VBRun>SendMessage
VBRun>Cleanup

Endif

Label>end


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

Post by Marcus Tettmar » Mon Jul 11, 2011 4:49 pm

Maybe try doubling up the \ characters. In some systems \ is an escape character. So replace all occurrences of "\" with "\\" and see what happens.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Michel
Newbie
Posts: 17
Joined: Fri May 20, 2011 2:12 pm
Location: Ottawa

Post by Michel » Mon Jul 11, 2011 6:26 pm

Found it... after trail and error

Add a single quote after the BACKSLASH

From:
\\My Server\MY_folder


To:
\'\'My Server\'My_folder

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