attachment with vbscript

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

attachment with vbscript

Post by timle » Tue Jan 03, 2017 10:56 pm

Sendmail is not working with exchange successfully since they have all the rule and relay server in place. I found vb script sample in this forum that will send email using outlook, which works good, but in the sample code, the attachment is hardcode in the function is there a way to make it into a variable. I have no knowledge on VB

objMsg.Attachments.Add "C:\daily_report.txt" ( this is in the sample and it works)

I wish I can do this
objMsg.Attachments.Add = (report)

let>report=C:\daily_report.txt


thank you for your input

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

Re: attachment with vbscript

Post by Marcus Tettmar » Wed Jan 04, 2017 10:11 am

Yes, in the same way you would any VBScript function, e.g. ..

Code: Select all

VBSTART
Sub SendEmail(to,from,bla,attachmentfile)
 ... 
 objMsg.Attachments.Add attachmentfile
 ... 
 bla bla
End sub
VBEnd

VBEval>SendEmail,blato,blafrom,bla,c:\some\file.txt
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Re: attachment with vbscript

Post by timle » Wed Jan 04, 2017 4:11 pm

works great !

thanks

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