all groups > sql server dts > january 2004 >
You're in the

sql server dts

group:

CDO script in DTS


CDO script in DTS Perry Provost
1/31/2004 12:55:07 PM
sql server dts:
Hi,
I have created a VBScript in an ActiveX object using CDO 1.21 to
connect to our Exchange server, look for an email with a specific Subject
Line and save the attachments into a directory folder on the server. The
attachments contain raw data which are later imported into tables.
The script runs perfectly from the Microsoft script editor. When I
execute the script in the opened DTS package, it runs fine. However, when I
run the DTS package as a SQL job, the package fails with the error the
MAPI_E_LOGIN_FAILED. I should mention that when I run the opened DTS package
manually, I am logged in using the same account as the SQL Server Agent. All
other mail operations in both DTS packages and SQL Mail work fine. I am
using Windows Server 2003/SQL2000 Enterprise/Outlook 2002 with all the
latest patches.

Any ideas why the script fails?

Perry Provost
perry.provost@hp.com

Re: CDO script in DTS Perry Provost
2/1/2004 4:26:35 PM
Discovered the problem. Turns out that not only does the job have to be
owned by the SQL Agent Service account, which I did have set, but so does
the DTS package itself. The DTS package was owned by an sysadmin on the
server, but not the same admin as the SQL Agent Service account. Once I
re-saved the DTS package with the SQL Agent Service account as the owner,
the script ran fine.

Thanks.


[quoted text, click to view]

Re: CDO script in DTS Darren Green
2/1/2004 7:01:46 PM
In message <uUwMeNC6DHA.3308@TK2MSFTNGP11.phx.gbl>, Perry Provost
<perry.provost@hp.com> writes
[quoted text, click to view]

When running this manually you are logged on as the SQL Agent service
account, but is this on the server or your desktop? If not try it on the
server.

Is the job owned by a sysadmin, if not it will not execute under the
context of the SQL Agent service account, instead it uses the proxy
account.

If none of the above helps, it could be something esoteric with CDO, and
I am not expert on CDo, but since it sounds like permissions, I would
add some code to the ActiveX Script that writes out the current user
(see WScript.Network object) to double check it really is executing
under the user you think.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org
AddThis Social Bookmark Button