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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB script sends file w/ attachment, corrupts attachment

Status
Not open for further replies.

hookahmasta

IS-IT--Management
Aug 5, 2005
31
US
I made myself a nice little VB Script, partly inspired by some feedback here, that...

a. Opens Excel
b. Opens file
c. Runs Macro which
c1. Runs a pivot refresh on the Excel file
c2. Does a print to the Adobe "printer", thus creating a PDF file in a specific directory
d. Quits Excel
f. Sends the PDF file out to specific receipents.

The last step, step F, is where I'm getting tripped up. For some reason, the PDF file, when it arrives in my mailbox, it's corrupted, with the message "An unrecognized token '(insert random character' was found", thus resulting in a blank PDF file. I've verified that the original PDF file is fine, since I can open that without a problem. Here's the last part of the script, which sends the file.

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "(email address)"
objEmail.To = "(email addresses)"
objEmail.Subject = "MACROS RULE!"
objEmail.Textbody = "blah blah blah"
objEmail.AddAttachment "(file location)"
objEmail.Send
Set objEmail = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top