mapi.session with Outlook 2003 Window 7 pro 64bit

rberke used Ask the Experts™
I am trying to write vba to get internet headers from email.  

The only CDO tool I see on my window 7 machine  is CDO for windows 2000 library, and that does not help.

I copied a CDO.DLL from an xp machine to C:\aaatmp\ on my windows 7, and set a reference to cdo 1.21.

Now the following code compiles but stops at errLine:
Activex component can't create object.

Any ideas?
Sub test()
Dim item As MailItem
For Each item In ActiveExplorer.Selection
Call FullHdrs(item)
 MsgBox getMailAddressesfromMail(item)
 ' MsgBox getMailHeader(item)

Public Function FullHdrs$(MI As MailItem)

Static MS As New MAPI.Session ' Maintain to suppress prompts

Dim CU$ ' Current user
Dim MM As MAPI.Message ' MAPI message, has headers

On Error GoTo MS_LOGON ' Test if session logged on by
CU$ = MS.CurrentUser ' trying to access its user
GoTo MS_LOGGED_ON ' Yes, skip logon

MS_LOGON: ' No, use default profile, this
MS.Logon , , False, False ' session, no dialog for at
Resume MS_LOGGED_ON ' most one security prompt

MS_LOGGED_ON: ' Resume normal error handing
On Error GoTo 0
' Use Outlook ID to get MAPI msg
Set MM = MS.GetMessage(MI.EntryID)
' MAPI msg has the full headers

End Function

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Infrastructure and Database Design Consultant
First browse through this, if you haven't already.



Somehow, I never thought about checking control panel > programs.  Sometimes I can be brain dead.

I deleted the version that I had copied from XP to my windows 7 machine

then, I changed Outlook to add the collaborative data objects, and now cdo 1.21 shows properly and works fine.

Your link gave me the idea, so you get the points.

Thanks Image shows that CDO was not initially installed
Francis OmorutoInfrastructure and Database Design Consultant

You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial