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!

MAPI is not working from task scheduler

Status
Not open for further replies.

himridul

Programmer
Jun 23, 2003
62
US
HI, I've a simple batch file which calls the below vbs script to send email using MAPI. I've scheduled the batch script through windows scheduler and it's working fine when I set the task as "Run only when user is logged on". I manually run the job from task scheduler, and I get email everytime I run it. Also I'm one of the Administrators on this server.

Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
ns.logon "","",true,false
Set newMail = ol.CreateItem(olMailItem)
continued .....

However when I set the task as "Run whether user is logged on or not", it invokes the batch file, however it never finishes. I run this manually from task scheduler and it never gets completed. After debugging I find that, it's stuck on the below line, it seems like it can't open outlook when running as "Run whether user is logged on or not".
Set ol = WScript.CreateObject("Outlook.Application")

I tried all the options, security, start in, priority etc., but nothing worked. Will it ever work with MAPI while "Run whether user is logged on or not" option is set or will I have to use CDO to resolve this issue? I need to make this work when we logged off from the server so that it monitors 24 hours and sends email when there is an error in server. Thanks!

My server OS : Windows Server 2008 Enterprise SP2
Also, fyi, i've outlook 2007 SP2 installed and configured for a shared email box in the server. So, when it sends an email,it'll come from shared email box.
 
when I check the event viewer in server after running the task with "Run whether user is logged on or not" option, I see application error with the below details:
Faulting application OUTLOOK.EXE, version 12.0.6423.1000, time stamp 0x49b08185, faulting module OUTLOOK.EXE, version 12.0.6423.1000, time stamp 0x49b08185, exception code 0xc0000005, fault offset 0x0000bfad, process id 0x2ccc, application start time 0x01cd12929c2c4f79.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top