April 14, 2004 at 3:51 pm
Has anyone had experience trying to create a 'MAPI.Session' object within an activeX script task in a DTS package? The SQL Server service is running under a valid domain account that has an Exchange mailbox. An email profile has been created on the server and it is valid. I want to connect to the server email mailbox to get a count of messages... ...long story. I have tried using something like the following....
' Declarations ***************************************************
Dim objSession ' Mail session object
Dim objMessage ' Mail message object
Dim objRecip ' Mail recipient object
' Begin script
Const strProfileName = "SQLSERVER"
' Create MAPI session object
Set objSession = CreateObject("MAPI.Session")
****************************************************
Everytime I get an error... like shown below...
DTSStep_DTSActiveScriptTask_1, Error = -2147220482 (800403FE) Error string: Error Code: 0 Error Source= Microsoft VBScript runtime error Error Description: ActiveX component can't create object: 'MAPI.Session' Error on Line 15
I can succesfully test the profile name on the SQL Mail configuration dialog box, so I know that my SQLServer can open and close a mapi.session using the profile... but I can't get a session to stick in a DTS activeX script.
Is this even possible??
I have even tried running the code while logged onto the server (under the SQLServer service account) with Outlook running... and I still get the same error.
April 15, 2004 at 7:27 am
Sounds like you may not have the MS Collaberation Data Objects installed. They do come with MS Office, but are not installed by default. You have to run the Office setup as Custom and install them.
An excellent web page with lots of examples can be found at http://www.cdolive.com/cdo5.htm
A couple of other things to make sure of are:
- Make sure that you sure the latest CDO Dlls. I use the ones that come with MS-Office XP/2003. Older versions seem to cause problems.
- The ActiveX script only seems to work for me in DTS if it is run on the Main Package thread.
April 16, 2004 at 9:44 am
Thanks for the reply... You were right I didn't have the CDO components loaded.
I installed them from the office setup CD.
Now the line of code that creates the MAPI.Session works... but
(and there is always a but...)
I can't get the logon method of the session object to work. I have tried two different options... one with the profilename and the other with the profileinfo. Neither one works.
I have included a snippet of my script code below... (both login options are shown but some code is commented out..)
I trap for an error number (or 'Unknown' currentuser property) after attempting to log into to the mapi session. I always get an error which sends me to my logic of of returning a failed task exectution.
I have trapped the err # ... it is -2147219963. The currentuser property is always 'NULL'.
Any thoughts?
I thought that logging into the session would be easy after getting the object created. I have done this in other vbs code before, but never in a DTS package.
*********************************************
Dim strProfileInfo
Const strProfileName = "SQLSERVER"
'This would be the Outlook Created profile name from the server
strProfileInfo = "EXCHSRVR" & Chr(10) & "SQLSERVER&my.domain"
'This would be the name of the Exchange server and
'the smtp email address of the account in exchange.
' Create MAPI session object
Set objSession = CreateObject("MAPI.Session")
on error resume next
' Try and logon to current MAPI session
objSession.Logon strProfileName, ,False, True
'objSession.Logon "", "", False, True, 0, False, strProfileInfo
If Err.Number <> 0 Or objSession.CurrentUser = "Unknown" Then
Main = DTSTaskExecResult_Failure
Else
*********************************************
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply