Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX Component Cant Create Object("mapi.session")

Status
Not open for further replies.

dorinda

Programmer
Jan 30, 2003
6
GB
Hi there, i was wondering if anyone could possibly help me.
I am working on a macro in excel which automatically sends an email when saved.
The email has to be sent to a group, and the code i have is :

Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim Msg As String
Dim sProfile As String

'create the Session object
Set objSession = CreateObject(&quot;mapi.session&quot;)<--ERROR HERE

'log onto the mapi session using the predefined profile
sProfile = &quot;VBAMailProfile&quot;
objSession.Logon profileName:=sProfile

'add a new message to the outbox
Set objMessage = objSession.Outbox.Messages.Add

Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = &quot;GrpTest&quot;
objRecipient.Resolve

'send the message without requiring user intervention or showing the message
objMessage.Send showDialog:=False

'Log off the session
objSession.Logoff

Now, this seems to work on some machines and not others. I am thinking there is a missing .dll file but im not sure which one. The computer that doesnt work also didnt have the vbamailprofile set up on the machine, but I already tried to set one up. Giving the fact that it stops before this line of code, it indicates there is a problem with the mapi session.
It worked on the computer when it was running NT, but it has since been upgraded to windows 2000 professional..


My knowledge about mapi sesions is very limited, and i'd appreciate any ideas or solutions to this problem !

Many Thanks,
Dorinda
 
Thank you Soooo much!
I'll try it out on monday when im back in at work
*crosses fingers it will work* :)

Dorinda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top