Extracting smtp addresses from Outlook 
Author Message
 Extracting smtp addresses from Outlook

I'm trying to update email addresses in a database.  When
I tried the VBA AddressLists, AddressEntries and
AddressEntry.Address property I got the X400 address
rather than the smtp address.  I used AddressEntry.Details
method but this only displays the Properties window to the
user.  The Email-Addresses tab of the window does display
the smtp address of the person.  Is there any way to get
the smtp address with these objects?  Is there a hidden
property such as AddressEntry.SmtpAddress that will give
me what I want?

Tried another angle, exported the GAL to details.oab file
on harddisk.  This file contains the smtp addresses,
however it is a very inhospitable format.  I would have to
traverse it looking for funny characters, and also it is
all serial which means it will take a long time.  I have
some siz thousands addresses to update.  Can VBA access
the details.oab file, are there specific methods to
traverse it?  

Tx for the help,

EB



Sat, 08 Jan 2005 03:33:11 GMT  
 Extracting smtp addresses from Outlook
Enis,

The following code should do the trick....

G

Sub getemailaddress()

Const CdoPR_SMTP_ADDRESS = &H39FE001E

Set oSession = Application.CreateObject("MAPI.Session")

  RetCode = oSession.Logon(Application.GetNameSpace("MAPI").CurrentUser, "",
False, False, 0)

  Set oNewMessage = oSession.Outbox.Messages.Add
  Set oNewRecip = oNewMessage.Recipients.Add(oSession.CurrentUser)

  oNewRecip.Resolve

  Set oNewUser = oNewRecip.AddressEntry
  Set NewFields = oNewUser.Fields
  eMailAddress = NewFields.Item(CdoPR_SMTP_ADDRESS)

  MsgBox eMailAddress

End Sub


Quote:
> I'm trying to update email addresses in a database.  When
> I tried the VBA AddressLists, AddressEntries and
> AddressEntry.Address property I got the X400 address
> rather than the smtp address.  I used AddressEntry.Details
> method but this only displays the Properties window to the
> user.  The Email-Addresses tab of the window does display
> the smtp address of the person.  Is there any way to get
> the smtp address with these objects?  Is there a hidden
> property such as AddressEntry.SmtpAddress that will give
> me what I want?

> Tried another angle, exported the GAL to details.oab file
> on harddisk.  This file contains the smtp addresses,
> however it is a very inhospitable format.  I would have to
> traverse it looking for funny characters, and also it is
> all serial which means it will take a long time.  I have
> some siz thousands addresses to update.  Can VBA access
> the details.oab file, are there specific methods to
> traverse it?

> Tx for the help,

> EB



Sun, 09 Jan 2005 03:52:44 GMT  
 Extracting smtp addresses from Outlook
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

Quote:
>Enis,

>The following code should do the trick....

>G

>Sub getemailaddress()

>Const CdoPR_SMTP_ADDRESS = &H39FE001E

>Set oSession = Application.CreateObject("MAPI.Session")

...


Sun, 09 Jan 2005 05:54:35 GMT  
 Extracting smtp addresses from Outlook
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


Quote:
> 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")

> ...



Mon, 10 Jan 2005 06:16:36 GMT  
 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")

> > ...



Wed, 12 Jan 2005 00:35:17 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Using Outlook Library to extract SMTP addresses

2. smtp email addresses in the Outlook global address list

3. SMTP mail name extract from Outlook

4. Allowing outlook to choose smtp address

5. getting smtp-address from outlook

6. Need a program to extract email addresses from MS Outlook 2000 folders/messages

7. Using VB.Net to extract Outlook 2000 addresses

8. Extract email addresses in an outlook object?

9. SMTP address vs. Exchange address (simple, I hope)

10. Retrieve SMTP email addresses of GAB address entries

11. Obtaining SMTP Address from Global Address Book

12. Updating email address in Outlook from VB / Outlook ignores changes

 

 
Powered by phpBB® Forum Software