dbTalk Databases Forums  

DTS job fails if scheduled on VB email step.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DTS job fails if scheduled on VB email step. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mutley1
 
Posts: n/a

Default DTS job fails if scheduled on VB email step. - 01-24-2006 , 05:58 AM






Hi All,

I have a package that sends a mail using VB as opposed to sendmail (I'm no
expert on VB so apologies in advance). Basically it will retrieve the users
that match criteria, insert images and information and send the mail. This
works fine from DTS designer, but when run as a scheduled job, or using
windows scheduler and a batch file, it fails with the error below. Beginning
of VB code below. I have included line numbers as per the VB editor sees it.

Error Source: Microsoft Data Transformation Services (DTS) Package
Error Description:Error Code: 4096
Error Source= Microsoft Outlook
Error Description: Could not complete the operation because the service
provider does not support it.

Error on Line 18

Error code: 800403FE
\Error Help File:sqldts80.hlp
Error Help Context ID:4500

I have seen numerous posts where no resolution was specifically found (for
my issue), but here's the answers to a few questions that I know I'll be
asked:

1. Outlook is installed on the server.
2. I am running the package when actually logged onto the server.
3. I am logged in as the SQL Agent domain account on the server.
4. The said domain account DOES have access to the outlook profile.
5. It works every time from DTS designer - only fails when scheduled via SQL
agent or Windows Scheduler.
6. Windows Server 2000 (SP3) and SQL 2000 (SP3), Outlook 2000.

CODE:
0'************************************************ *****
1' Visual Basic ActiveX Script
2'************************************************ *****
3
4Function Main()
5
6'create new Outlook MailItem
7 Set objApp = CreateObject("Outlook.Application")
8Set mapiNameSpace = objApp.GetNameSpace("MAPI")
9 Set l_Msg = objApp.CreateItem(olMailItem)
10
11' initialize CDO session
12 'Set oSession = CreateObject("MAPI.Session")
13 'oSession.Logon "xxxxxxx", "xxxxxxx", False, False
14
15'add graphic as attachment to Outlook message
16' change path to graphic as needed
17 Set colAttach = l_Msg.Attachments
18 Set l_Attach = colAttach.Add("C:\Program Files\picture.jpg")
19 l_Msg.Close olSave
20 strEntryID = l_Msg.EntryID
21 Set l_Msg = Nothing
22' *** POSITION CRITICAL *** you must dereference the
23' attachment objects before changing their properties
24' via CDO
25 Set colAttach = Nothing
26 Set l_Attach = Nothing


I believe that there is some kind of permissions issue when it tries to
insert the JPG into the mail as a scheduled job. As I say, it works when I am
logged in as the SQL Agent and Outlook is completely closed. I see an outlook
email window pop up briely on the screen (split second) when it creates the
mail. However, whenever it is scheduled via SQL or batch file, it fails.

Matt.


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: DTS job fails if scheduled on VB email step. - 01-24-2006 , 03:06 PM






Hello mutley1,


Ok So you've tried virtually everything I would have.

What account owns the SQL Server Agent Job? member of sysadmin? This matters
as to what the execution account will be.

Allan



Quote:
Hi All,

I have a package that sends a mail using VB as opposed to sendmail
(I'm no expert on VB so apologies in advance). Basically it will
retrieve the users that match criteria, insert images and information
and send the mail. This works fine from DTS designer, but when run as
a scheduled job, or using windows scheduler and a batch file, it fails
with the error below. Beginning of VB code below. I have included line
numbers as per the VB editor sees it.

Error Source: Microsoft Data Transformation Services (DTS) Package
Error Description:Error Code: 4096
Error Source= Microsoft Outlook
Error Description: Could not complete the operation because the
service
provider does not support it.
Error on Line 18

Error code: 800403FE
\Error Help File:sqldts80.hlp
Error Help Context ID:4500
I have seen numerous posts where no resolution was specifically found
(for my issue), but here's the answers to a few questions that I know
I'll be asked:

1. Outlook is installed on the server.
2. I am running the package when actually logged onto the server.
3. I am logged in as the SQL Agent domain account on the server.
4. The said domain account DOES have access to the outlook profile.
5. It works every time from DTS designer - only fails when scheduled
via SQL
agent or Windows Scheduler.
6. Windows Server 2000 (SP3) and SQL 2000 (SP3), Outlook 2000.
CODE:
0'************************************************ *****
1' Visual Basic ActiveX Script
2'************************************************ *****
3
4Function Main()
5
6'create new Outlook MailItem
7 Set objApp = CreateObject("Outlook.Application")
8Set mapiNameSpace = objApp.GetNameSpace("MAPI")
9 Set l_Msg = objApp.CreateItem(olMailItem)
10
11' initialize CDO session
12 'Set oSession = CreateObject("MAPI.Session")
13 'oSession.Logon "xxxxxxx", "xxxxxxx", False, False
14
15'add graphic as attachment to Outlook message
16' change path to graphic as needed
17 Set colAttach = l_Msg.Attachments
18 Set l_Attach = colAttach.Add("C:\Program Files\picture.jpg")
19 l_Msg.Close olSave
20 strEntryID = l_Msg.EntryID
21 Set l_Msg = Nothing
22' *** POSITION CRITICAL *** you must dereference the
23' attachment objects before changing their properties
24' via CDO
25 Set colAttach = Nothing
26 Set l_Attach = Nothing
I believe that there is some kind of permissions issue when it tries
to insert the JPG into the mail as a scheduled job. As I say, it works
when I am logged in as the SQL Agent and Outlook is completely closed.
I see an outlook email window pop up briely on the screen (split
second) when it creates the mail. However, whenever it is scheduled
via SQL or batch file, it fails.

Matt.




Reply With Quote
  #3  
Old   
Mutley1
 
Posts: n/a

Default Re: DTS job fails if scheduled on VB email step. - 01-25-2006 , 02:29 AM



Hi Allen,

Yes, it's a domain account with sysadmin in SQL, administrator on the box,
access to the profile it's trying to send with....basically a demi God in the
environment!

The one other thing I have done is dcomcnfg.exe and added the account into
the default perms. We have not had the criteria met yet since i did that to
cause a mail to be sent (live system so can't force through), but it's
bugging me big time now. I knw the permissions are all correct. Short of
being made President, I don't believe this account can get any higher!!!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.