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.
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.