Outlook email address retrieval - InfoPath Dev
in

InfoPath Dev

Outlook email address retrieval

Last post 05-02-2006 06:09 AM by nukkumatti. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-14-2005 01:04 PM

    • gds140
    • Not Ranked
    • Joined on 07-14-2005
    • Posts 5

    Outlook email address retrieval

    I'm currently working on an Infopath form where I need to pop up an outlook address book and then populate a text box with an email address that corresponds to the name selected from the address book. I have the book popping up but haven't had any luck grabbing the email address. I can get the name, but not the email address. Anyone have any idea how to go about doing this? Thanks in advance for any suggestions.
  • 07-14-2005 11:46 PM In reply to

    Re: Outlook email address retrieval

    Hi gds, Welcome to the forum!
    If you provide the code how you are poping up outlook address book and how you are getting Name from it, we can try and check how we will be able to get the email address from that.
    If the code is way too big you can email me.


    Agni
    InfoPathDev India
  • 07-15-2005 06:56 AM In reply to

    • gds140
    • Not Ranked
    • Joined on 07-14-2005
    • Posts 5

    Re: Outlook email address retrieval

    Agni, here is the code snippet. It currently populates a text box with the name from the address book, but not the email.

    Sub AppSubsystemOwnersBtn_OnClick(eventObj)
    Dim I
    Dim strRecip
    Dim Owners

    On Error Resume Next
    strDialogCaption = "Select " & strUDFieldName
    Set objCDO = CreateObject("MAPI.Session")
    'Piggyback on existing Outlook session
    objCDO.Logon "", "", False, False, 0
    If Err Then
    MsgBox "Could not establish CDO session!", vbCritical
    End If
    Set Recips = objCDO.AddressBook(Nothing, _
    strDialogCaption, False, True, 1, strShortName, "", "", 0)
    'These recipients have been resolved by forceResolution argument above
    If Not Err Then
    For i = 1 To Recips.Count
    strRecip = strRecip & Recips(i).Name & "; "
    Next
    If strRecip <> "" Then
    strRecip = Left(strRecip, Len(strRecip)-2)
    strUDFieldName = strRecip

    set Owners = XDocument.DOM.selectSingleNode("my:myFields/my:AppSubsystemOwners")
    Owners.text = strRecip
    End If
    End If

    objCDO.Logoff

    End Sub
  • 07-15-2005 06:59 AM In reply to

    • gds140
    • Not Ranked
    • Joined on 07-14-2005
    • Posts 5

    Re: Outlook email address retrieval

    Sorry about that, this will be easier to read:


    Sub AppSubsystemOwnersBtn_OnClick(eventObj)
    Dim I
    Dim strRecip
    Dim Owners

    'On Error Resume Next
    strDialogCaption = "Select " & strUDFieldName
    Set objCDO = CreateObject("MAPI.Session")

    'Piggyback on existing Outlook session
    objCDO.Logon "", "", False, False, 0

    If Err Then
    MsgBox "Could not establish CDO session!", vbCritical
    End If

    Set Recips = objCDO.AddressBook(Nothing, _
    strDialogCaption, False, True, 1, strShortName, "", "", 0)
    'These recipients have been resolved by forceResolution argument above

    If Not Err Then
    For i = 1 To Recips.Count
    strRecip = strRecip & Recips(i).Name & "; "
    Next

    If strRecip <> "" Then
    strRecip = Left(strRecip, Len(strRecip)-2)
    strUDFieldName = strRecip

    set Owners = XDocument.DOM.selectSingleNode("my:myFields/my:AppSubsystemOwners")
    Owners.text = strRecip
    End If
    End If

    objCDO.Logoff

    End Sub
  • 03-09-2006 08:23 AM In reply to

    • SDD
    • Not Ranked
    • Joined on 03-09-2006
    • Posts 1

    Re: Outlook email address retrieval

    Dear gds/Agni,
    I'am trying to solve the same problem, trying to retrieve the mail address and 'browsing' the outlook address book, below code / question seems not to be answered/finalized, did you succeed in this??

    I'am getting an error concerning the MAPI control, is it an external ActiveX needed to be registered?

    Hope you can help,

    BR,
    SDD


    quote:
    Originally posted by gds140

    Sorry about that, this will be easier to read:


    Sub AppSubsystemOwnersBtn_OnClick(eventObj)
    Dim I
    Dim strRecip
    Dim Owners

    'On Error Resume Next
    strDialogCaption = "Select " & strUDFieldName
    Set objCDO = CreateObject("MAPI.Session")

    'Piggyback on existing Outlook session
    objCDO.Logon "", "", False, False, 0

    If Err Then
    MsgBox "Could not establish CDO session!", vbCritical
    End If

    Set Recips = objCDO.AddressBook(Nothing, _
    strDialogCaption, False, True, 1, strShortName, "", "", 0)
    'These recipients have been resolved by forceResolution argument above

    If Not Err Then
    For i = 1 To Recips.Count
    strRecip = strRecip & Recips(i).Name & "; "
    Next

    If strRecip <> "" Then
    strRecip = Left(strRecip, Len(strRecip)-2)
    strUDFieldName = strRecip

    set Owners = XDocument.DOM.selectSingleNode("my:myFields/my:AppSubsystemOwners")
    Owners.text = strRecip
    End If
    End If

    objCDO.Logoff

    End Sub


  • 05-02-2006 06:09 AM In reply to

    Re: Outlook email address retrieval

    Hey all,

    i need to do the same using C#. It should be possible for the user to select an email address from the addressbook and this address should be written into a textfield on my form.

    Can someone help me with this.

    Thx
    Listen to Motörhead cos they play Rock'n Roll :)
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.