Trapping errors in Sendemail vb script

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
johnsis
Newbie
Posts: 10
Joined: Fri Nov 30, 2007 6:59 pm

Trapping errors in Sendemail vb script

Post by johnsis » Sat Sep 27, 2008 3:01 pm

I'm trying to trap for errors in sendemail vbscript. This is usually because of a bad smtp server. I've used On error Resume next and can see the err.number 0 within the vbscript but I can't get that to return within macro scheduler so I can write the error to a text file. Any ideas?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 27, 2008 5:07 pm

How about writing the error to a text file using the same VBScript? If err.number 0 then write err.number to text file.

Then continue with Macro Scheduler?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by Marcus Tettmar » Sat Sep 27, 2008 6:19 pm

Just set the error number to a global VBScript variable and then retrieve it with VBEval:

Code: Select all

VBSTART

Dim gErrorNum

Sub SomeSub
  On Error Resume Next
  .. do something
  gErrorNum = Err.Number
End SomeSub

VBEND

VBRun>SomeSub
..
VBEval>gErrorNum,locErrorNum
MessageModal>Error: %locErrorNum%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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