CDO object error in a scheduled task script

Author Message
nakra

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 3/16/2011
  • Status: offline
CDO object error in a scheduled task script Monday, January 16, 2012 7:28 AM (permalink)
0
Hello,
I have a problem in receiving emails using a vbscript running as a scheduled task. But the same script runs perfectly when is launched from DOS console. As a scheduled task it returns an error message like: CDO.message SendUsing configuration value is invalid.
For the simplicity, I won't post the entire script since the only part that doesn't work si the SendeMail procedure.
 
 Sub SendeMail(sFrom, sTo, sSubject, sInfo)
 Set objMessage = CreateObject("CDO.Message")
 oMessage.Subject = sSubject
 oMessage.From = sFrom
 oMessage.To = sTo
 oMessage.TextBody = sInfo
 oMessage.Send
 Set oMessage = Nothing
End Sub 

Why the script runs without any error from command prompt, but as scheduled job returns error?
The scheduled job was created with target app being wither the script name, either "cscript.exe script_name".
 
#1
    59cobalt

    • Total Posts : 969
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:CDO object error in a scheduled task script Monday, January 16, 2012 9:37 AM (permalink)
    0
    You probably should provide an explicit SendUsing configuration. Do you want to relay the message via an SMTP server on localhost or via an external SMTP server?
     
    #2
      nakra

      • Total Posts : 10
      • Scores: 0
      • Reward points : 0
      • Joined: 3/16/2011
      • Status: offline
      Re:CDO object error in a scheduled task script Tuesday, January 17, 2012 8:49 AM (permalink)
      0
      Yes 59cobalt, it was because I didn't provide an explicit SendUsing configuration. Thanks for the tip.
      After providing the necessary configuration it works. To answer your question, I'm using an external SMTP server to relay the message.
       
      Still.. I don't understand why the script needs that extra configuration when running as a job, but when launched from command prompt it needs none. Why is that difference?
       
      #3
        ebgreen

        • Total Posts : 8219
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:CDO object error in a scheduled task script Tuesday, January 17, 2012 9:21 AM (permalink)
        0
        Well I can't speak to this specific situation, but I can say that scheduled tasks run in the system context by default and not in the user context, so I suspect that you need the explicit configuration due to that.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          nakra

          • Total Posts : 10
          • Scores: 0
          • Reward points : 0
          • Joined: 3/16/2011
          • Status: offline
          Re:CDO object error in a scheduled task script Wednesday, January 18, 2012 7:07 AM (permalink)
          0
          Yes, it could be.
           
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9