Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

MAPI is not working from task scheduler

MAPI is not working from task scheduler

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.

RE: MAPI is not working from task scheduler

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close