Outlook Addressbook - InfoPath Dev
in

InfoPath Dev

Outlook Addressbook

Last post 09-11-2006 03:28 AM by praveen.prabhakaran. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-21-2005 05:30 AM

    Outlook Addressbook

    Hi all,
    In my Visual Studio .NET Infopath project i need to open the Outlook Addressbook to make the user insert an email address. Can you give me some ideas to open che AddressBook and get the address selected?

    Thank u.
  • 12-21-2005 09:51 AM In reply to

    This is how I did it using VB.Net. Note that you must have the CDO library installed with MS Office to do this. This returns a string of recipients delimited by a ; and you can do with them whatever you want.


    Public Function AddRecipientsViaCDO()
    Const cdoE_USER_CANCEL = &H80040113
    Dim objSession As MAPI.Session
    Dim colCDORecips
    Dim Recipstring
    Dim objCDORecip
    Dim objRecip
    ' Start CDO session
    objSession = CreateObject("MAPI.Session")
    objSession.Logon(, , False, False)
    On Error Resume Next
    ' show address book
    colCDORecips = objSession.AddressBook(, _
    "Pick Names", , , 1, _
    "Recipients")
    If Err.Number = 0 Then
    For Each objCDORecip In colCDORecips
    If Recipstring = "" Then
    Recipstring = objCDORecip.AddressEntry.Name
    Else Recipstring = Recipstring & ";" & objCDORecip.AddressEntry.Name
    End If
    If Err.Number = 287 Then
    ' security block triggered
    MsgBox("Outlook cannot add " & _
    "recipients, because " & _
    "you clicked No on the " & _
    "e-mail address access " & _
    "dialog. You need to try " & _
    "again and click Yes " & _
    "this time.", , _
    "E-mail Address Access")
    Exit For
    End If
    Next
    ElseIf Err.Number = cdoE_USER_CANCEL Then
    MsgBox("You must select a recipient")
    AddRecipientsViaCDO()
    End If
    On Error GoTo 0
    AddRecipientsViaCDO = Recipstring
    End Function
  • 09-11-2006 03:28 AM In reply to

    Hi jeremyj,
    I have used your code but its giving Security warning..
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.