Results 1 to 2 of 2

Thread: Append Personal Address Book "RESOLVED"

  1. #1

    Thread Starter
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478

    Append Personal Address Book "RESOLVED"

    Hi , I would like to append all known clients of my clients table to the personal address book in outlook by code.

    Can this be done and how.

    I make use of the MAPISession object and MAPIMessages object.

    For each user which email adress is known i would append it to the PAB (Personal Address Book) if it doesn't exists.
    Last edited by swatty; Oct 23rd, 2002 at 05:21 AM.
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    VB Code:
    1. Private Sub UserForm_Initialize()
    2.    
    3.     Dim objOutlook As Object ' New Outlook.Application
    4.     Dim objNameSpace As Object 'NameSpace
    5.     Dim objDefFolder As Object 'MAPIFolder
    6. '    Dim objItem As Object 'Items
    7. '    Dim objConItem As Object 'ContactItem
    8. '    Dim objAddressList As Object 'AddressList
    9. '    Dim objAddressEntry As Object 'AddressEntry
    10.    
    11.     Dim lngContacts As Long, lngTemps As Long
    12.     Dim blnLeave As Boolean
    13.     Dim strInputtedLine As String, strSplitted() As String
    14.    
    15.     On Error Resume Next
    16.    
    17.     Me.MousePointer = fmMousePointerHourGlass
    18.    
    19. '---- initialize lists
    20.     lstContacts.Clear
    21.     lstContacts.ColumnCount = 5
    22.     lstContacts.ColumnHeads = False
    23.     lstContacts.ColumnWidths = "134;40;40;0;0"
    24.    
    25.     lstTemplates.Clear
    26.     lstTemplates.ColumnCount = 2
    27.     lstTemplates.ColumnWidths = "100;0"
    28.    
    29.    
    30. '---- Loop through contacts (Assume only one list)
    31. '    lstContacts.AddItem "A N Other"
    32. '    lstContacts.Column(1, lstContacts.ListCount - 1) = "4 The Green"
    33.    
    34.     Set objOutlook = CreateObject("Outlook.Application")
    35.     Set objNameSpace = objOutlook.GetNamespace("Mapi")
    36.        
    37.     Set objDefFolder = objNameSpace.GetDefaultFolder(10)
    38.  
    39.     For lngContacts = 1 To objDefFolder.Items.Count
    40.         With objDefFolder.Items(lngContacts)
    41.             lstContacts.AddItem
    42.             lstContacts.Column(0, lngContacts - 1) = Nnz(.FullName, "Unknown")
    43.             lstContacts.Column(1, lngContacts - 1) = IIf(Len(Nnz(.HomeAddress, "")) > 0, "Home", "")
    44.             lstContacts.Column(2, lngContacts - 1) = IIf(Len(Nnz(.BusinessAddress, "")) > 0, "Business", "")
    45.             lstContacts.Column(3, lngContacts - 1) = Nnz(.HomeAddress, "")
    46.             lstContacts.Column(4, lngContacts - 1) = Nnz(.BusinessAddress, "")
    47.         End With
    48.     Next
    49.        
    50.     objOutlook.Quit
    51.     Set objOutlook = Nothing
    52.    
    53.     Me.MousePointer = fmMousePointerDefault
    54.    
    55. End Sub
    The above I used in a Word application to grab the contacts and put them into a list box on a user form. It worked well, maybe you can use part of this to check the personal contacts..? Not sure if there is a faster way of searching the contacts for email addys already entered... or names...


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width