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("mapi.session"
<--ERROR HERE
'log onto the mapi session using the predefined profile
sProfile = "VBAMailProfile"
objSession.Logon profileName:=sProfile
'add a new message to the outbox
Set objMessage = objSession.Outbox.Messages.Add
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = "GrpTest"
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
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("mapi.session"
'log onto the mapi session using the predefined profile
sProfile = "VBAMailProfile"
objSession.Logon profileName:=sProfile
'add a new message to the outbox
Set objMessage = objSession.Outbox.Messages.Add
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = "GrpTest"
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