Outlook email address retrieval - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » Outlook email address retrieval Outlook email address retrieval Last post 05-02-2006 06:09 AM by nukkumatti. 5 replies. Page 1 of 1 (6 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 07-14-2005 01:04 PM gds140 Joined on 07-14-2005 Posts 5 Outlook email address retrieval Reply Contact 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 Agni Jonnalagadda Joined on 12-15-2004 India Posts 617 Re: Outlook email address retrieval Mark as Not AnswerMark as Answer... Reply Contact 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.AgniInfoPathDev India Agni / http://www.ggktech.com 07-15-2005 06:56 AM In reply to gds140 Joined on 07-14-2005 Posts 5 Re: Outlook email address retrieval Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 07-14-2005 Posts 5 Re: Outlook email address retrieval Mark as Not AnswerMark as Answer... Reply Contact 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 Joined on 03-09-2006 Posts 1 Re: Outlook email address retrieval Mark as Not AnswerMark as Answer... Reply Contact 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,SDDquote:Originally posted by gds140Sorry 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 nukkumatti Joined on 12-08-2005 Germany Posts 349 Re: Outlook email address retrieval Mark as Not AnswerMark as Answer... Reply Contact 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.
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
quote:Originally posted by gds140Sorry 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