[AccessD] Picking up Outlook address data etc.

Drew Wutka DWUTKA at marlow.com
Tue Apr 29 13:41:14 CDT 2003


Okay friend for life! <grin>
 
I put this code behind a command button on a VB form with a Listbox (List1):
 
Private Sub Command1_Click()
On Error Resume Next
Dim mps As MAPI.Session
Dim al As MAPI.AddressList
Dim ae As MAPI.AddressEntry
Dim fld As Field
Dim strTemp As String
Set mps = CreateObject("MAPI.Session")
mps.Logon , , , , , , "Main2.marlow.com" & vbLf & "Drew Wutka"
Set al = mps.GetAddressList(0)
For Each ae In al.AddressEntries
    strTemp = ae.Name
    For Each fld In ae.Fields
        If InStr(1, fld.Value, "@") > 0 Then strTemp = strTemp & " - " &
fld.Value
    Next
    Me.List1.AddItem strTemp
Next
 
Set ae = Nothing
Set al = Nothing
mps.Logoff
Set mps = Nothing
End Sub
 
Of course, you'll need to change the mps.Logon line, because it is logging
into my email (and it only does so because it uses the credentials of my
current logged on account.
 
But this code fills the listbox with every name (and their addressES) in the
Global Address List.
 
I must admit, I have never done this before...never needed to, so if you
have a more specific question, I'll have to research it a bit.
 
Drew

-----Original Message-----
From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk]
Sent: Tuesday, April 29, 2003 3:09 AM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Picking up Outlook address data etc.


Hi Drew
 
Thanks for the offer of help.
 
After reading around on CDO, ADSI etc I had a quick go just using the
Outlook object library and got this far:
 
Sub getGAL_click()
 
'this code based on MSKB article 313797
'tweaked by rozc
 
Dim oApp As Outlook.Application
Set oApp = New Outlook.Application
 
Dim oNS As Outlook.NameSpace
Set oNS = oApp.GetNamespace("mapi")
 
'oNS.Logon "rozc", "avalon", False, True
'logon information does not seem to be required if you are happy to use
'the current session profile.
 
Dim oDLs As Outlook.AddressLists
Set oDLs = oNS.AddressLists
 
Dim oGAL As Outlook.AddressList
Set oGAL = oDLs.Item("Global Address List")
 
Dim oEntries As Outlook.AddressEntries
Set oEntries = oGAL.AddressEntries
 
Dim oEntry As Outlook.AddressEntry
 
Dim i As Integer
 
For i = 1 To oEntries.Count
    Set oEntry = oEntries.Item(i)
    Debug.Print oEntry.Name
Next
 
'oNS.Logoff
 
End Sub
 
This gets me a list of the correct names in the global address list.
Unfortunately the address attribute available here is a path to a mailbox,
not an email address - which I have't tried using for anything but I don't
imagine it would be much use.
 
I also haven't tried using the Name as the recipient but I'm hoping that
Outlook will be able to resolve it. So, I maybe almost have something that
will work!
 
Where I got stuck with the CDO was in referencing the GAL - all the sample
code & Exchange viewers I could find got me into every other folder but. If
you can provide me with that, I'll be your friend for life :)
 
TIA
 
Roz

-----Original Message-----
From: Drew Wutka [mailto:DWUTKA at marlow.com] 
Sent: 29 April 2003 01:04
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Picking up Outlook address data etc.


Yes, CDO is free.  It's behind MAPI, which is a pain.  I personally find CDO
pretty easy to use.
 
Unless everyone wants me to clutter the list with sample code, if you email
me offline Roz, I can probably send what you are going to need piece meal.
 
Drew

-----Original Message-----
From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk]
Sent: Monday, April 28, 2003 9:22 AM
To: 'accessd at databaseadvisors.com'
Subject: [AccessD] Picking up Outlook address data etc.



Dear List 

Does anyone have the low-down on how to get data out of Exchange? We're
running Exchange 2000 with Office XP. 

What I need to be able to do is 
a) automatically mail certain pre-defined staff members at certain times
(singly and in groups), and 
b) allow people to send ad-hoc mails from the database, selecting from a
list of staff members or typing in mail addresses.

Currently we are entering all email addresses manually for the ad-hoc mails
and relying on a local table of mail addresses for the automated mails - a
ridiculous duplication of effort when all this stuff is on the system
already.

So.... All I've managed to find on MSDN are some references to something
called CDO which can be used to extend Exchange (though it's not wonderfully
clear in what ways), but I can't see how to get it and unless it's free I
can't have it anyway.

Can anyone help? 

TIA 

Roz 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030429/59c79710/attachment-0001.html>


More information about the AccessD mailing list