Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook address book

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
I have a routine that will:
a. Look to users Personal Address Book (PAB)
b. Check for specific address (A Public folder) and if this is not found add the address.
c. launch a custom eform from that folder.

the issue is that to send to a Public folder the folders address must be in the users PAB, and Outlook must resolve the addresses from the PAB rarther than any other Address book (e.g. GAL, Contacts).

Is there a way I can:
1. Set names to be checked from PAB first
2. (this ones not so important but would be nice) Create a PAB if one is not found.

Many thanks for your help in advance.

O Yea here's the code I use:

Code:
Public Sub ImportRequests()
'---------------------------------------------------------------------------------------
' Procedure : ImportRequests
' DateTime  : 22/Oct/2003 17:11
' Author    : Chris Hellings; 6021134
' Purpose   :
'---------------------------------------------------------------------------------------
'

    Dim olApp As Outlook.Application
    Dim olNSPace As NameSpace
    Dim olAddList As Outlook.AddressList
    Dim olAddEntries As Outlook.AddressEntries
    Dim olAddEntry As Outlook.AddressEntry
    Dim bItIsThere As Boolean
    Dim olPubFolder As Outlook.MAPIFolder
    Dim olForm As Outlook.MailItem
    
    On Error GoTo ImportRequests_Error

    Screen.MousePointer = vbHourglass
    
    Set olApp = New Outlook.Application
    Set olNSPace = olApp.GetNamespace("MAPI")
    Set olAddList = olNSPace.AddressLists("Personal Address Book")
    Set olAddEntries = olAddList.AddressEntries
    Set olAddEntry = olAddEntries.GetFirst
    Set olPubFolder = olNSPace.Folders("Public Folders").Folders("Clerical Support")

    
    Do Until olAddEntry Is Nothing

        If olAddEntry.Name = "Clerical Support" Then
'            It's there
            bItIsThere = True
            Exit Do
        End If
        
        Set olAddEntry = olAddEntries.GetNext
    Loop

    If Not bItIsThere Then
'        address not found
        Set olAddEntry = olAddEntries.Add("EX", "Clerical Support" _
        , "/o=Inland Revenue/ou=IR01/cn=Recipients/cn=CLERICAL SUPPORT9FBEA2D39FBEA2D39FBEA2D383F644246BFEF9")

        olAddEntry.Update

    End If
    
    Set olForm = olPubFolder.Items.Add("IPM.Note.Form Request")
    
    olForm.To = "Clerical Support"
    olForm.CC = ""
    olForm.BCC = ""
    olForm.Display
    
ImportRequests_Exit:

    Set olAddList = Nothing
    Set olAddEntries = Nothing
    Set olAddEntry = Nothing
    Set olApp = Nothing
    Set olNSPace = Nothing
   
    Screen.MousePointer = vbDefault

    On Error GoTo 0
    Exit Sub
    
NoPAB:
    
    MsgBox "The application couldn't find your Personal Address Book." & vbCrLf & _
        "Please ensure you have a Personal Address Book set up" & vbCrLf & _
        "and try again.", vbCritical, "Object not found"
    
    GoTo ImportRequests_Exit

ImportRequests_Error:
    If Err.Number = -2147221233 Then
        GoTo NoPAB
    End If
    
    MsgBox Err.Number & ", " & Err.Description
    GoTo ImportRequests_Exit
End Sub
[\code] 

Everybody body is somebodys Nutter.
 
Hello CC,

Check out an excellent site dedicated solely to Outlook. Also, if you get the Security prompts regarding someone accessing an email address you may need to use something like Redemption, a third party dll. It sells for around $200 and is royalty free, unlimited distribution. Good Luck!

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top