
Extracting smtp addresses from Outlook
Hi EB, try this out. You may need to reference a couple of libraries for
this to work - under Tools-->References, check the Microsoft Outlook Object
library, and you may also need to reference the CDO library which might not
be installed on your machine? Have a go anyway...
G
Sub GetGALInfo()
On Error Resume Next
Dim objABItems As Object
Dim strEmailAddress As String
Dim objCDOSession As Object
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon "Microsoft Outlook", "", False, False
Set objABItems = objCDOSession.CurrentUser.Fields
strEmailAddress = objABItems(&H39FE001E)
MsgBox strEmailAddress
Set objABItems = Nothing
objCDOSession.Logoff
Set objCDOSession = Nothing
End Sub
Quote:
> Sorry, yes, you would. I'd copied the code from an Outlook form. I'll
get
> the VBA code for this tomorrow at work.
> G
> > Tx for the code G. Where do I need to run it? I tried it
> > from Word VBA and Outlook VBA but got an error message for
> > both of them. The Word VBA gave "Compile Error: Method or
> > Datamember not found" for the CreateObject method. Sure
> > enough CreateObject doesnt show up in the intellisense
> > window when I put a dot after Application. Outlook VBA
> > gave me "Runtime error 'some strin g of numbers here',
> > Internal Application Error'. I tried replacing
> > Application with other stuff but still couldnt go
> > anywhere. Do I need VB 6 to run it? Otherwise any
> > suggestions? Tx much,
> > EB
> > >Enis,
> > >The following code should do the trick....
> > >G
> > >Sub getemailaddress()
> > >Const CdoPR_SMTP_ADDRESS = &H39FE001E
> > >Set oSession = Application.CreateObject("MAPI.Session")
> > ...