Outlook and InfoPath - InfoPath Dev
in

InfoPath Dev

Outlook and InfoPath

Last post 12-18-2008 02:06 AM by belote82. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 06-09-2005 01:51 AM

    • Haros
    • Not Ranked
    • Joined on 06-09-2005
    • Sweden
    • Posts 3

    Outlook and InfoPath

    Hi,

    When a user opens a form I would like their Outlook properties,
    E-mail address, First and last name to be filled in automatically in fields in the form.
    How can I do that?

    Regards,
    Hans
  • 06-09-2005 12:01 PM In reply to

    Hi Haros,
    Welcome to the Forum!
    I dont think we can really get the values from the Outlook properties using InfoPath SDK.
    Probably it is possible to get data from Outlook using .net code.

    Please post here if you find anything intresting.

    Agni
    InfoPathDev India
  • 06-10-2005 06:51 AM In reply to

    • Haros
    • Not Ranked
    • Joined on 06-09-2005
    • Sweden
    • Posts 3
    Hi,

    I got it to work with some VBScript.
    You have to be logged on to Outlook to get it to work.
    Now I have another problem and that is to get the script file
    script.vbs in my template together with a script.js file.
    I can't seem to get it in there when I allready have a js file.
    If someone can help me with that I would appreciate it.

    Here is my VBScript:

    Sub XDocument_OnLoad(eventObj)
    Dim cdoSession 'As MAPI.Session
    Dim cdoAddrEntry 'As AddressEntry
    Dim strData 'as string

    'VBScript does not recognize constants!
    ' Define them explicitly or use their value.
    dim CdoPR_DISPLAY_NAME
    dim CdoPR_EMAIL
    dim CdoPR_INITIALS
    dim CdoPR_GIVEN_NAME
    dim CdoPR_SURNAME
    Dim vbCRLF

    CdoPR_DISPLAY_NAME = &H3001001E
    CdoPR_EMAIL = &H39FE001E
    CdoPR_INITIALS = &H3A0A001E
    CdoPR_GIVEN_NAME = &H3A06001E
    CdoPR_SURNAME = &H3A11001E
    vbCRLF = chr(13) & chr(10)

    on error resume next

    'Start the CDO code to find a match.
    Set cdoSession = CreateObject("Mapi.session")
    cdoSession.Logon ,,false,false,0 'Use the existing Outlook session.
    if err.number <> 0 then msgbox "ERROR in logon: " & err.number & vbCRLF & err.description

    'Get the AddressEntry of the recipient/current user.
    Set cdoAddrEntry = cdoSession.CurrentUser
    if err.number <> 0 then msgbox "ERROR getting AddressEntry: " & err.number & vbCRLF & err.description


    'Get properties.
    strData = "Name: " & cdoAddrEntry.fields(CdoPR_DISPLAY_NAME)
    strData = strData & vbCRLF & "E-Mail: " & cdoAddrEntry.fields(CdoPR_EMAIL)
    strData = strData & vbCRLF & "First name: " & cdoAddrEntry.fields(CdoPR_GIVEN_NAME)
    strData = strData & vbCRLF & "Initials: " & cdoAddrEntry.fields(CdoPR_INITIALS)
    strData = strData & vbCRLF & "Last name: " & cdoAddrEntry.fields(CdoPR_SURNAME)

    If XDocument.DOM.selectSingleNode("//my:Status").text = "New" Then

    XDocument.DOM.selectSingleNode("//my:DisplayName").text = cdoAddrEntry.fields(CdoPR_DISPLAY_NAME)
    XDocument.DOM.selectSingleNode("//my:Email").text = cdoAddrEntry.fields(CdoPR_EMAIL)
    XDocument.DOM.selectSingleNode("//my:Initials").text = cdoAddrEntry.fields(CdoPR_INITIALS)
    XDocument.DOM.selectSingleNode("//my:GivenName").text = cdoAddrEntry.fields(CdoPR_GIVEN_NAME)
    XDocument.DOM.selectSingleNode("//my:SurName").text = cdoAddrEntry.fields(CdoPR_SURNAME)
    XDocument.DOM.selectSingleNode("//my:Status").text = "Old"

    End If

    'Explicitly release objects.
    cdoSession.logoff

    Set cdoAddrEntry = Nothing
    Set cdoSession = Nothing

    End Sub

    Regards,
    Hans
  • 12-16-2008 02:12 AM In reply to

    Is it possible to get it work in jscript?

    I have to know the department property from outlook in my form...

    Otherwise, is it possible to get the group from the active directory in jscript?

     

    thank you so much

     

    Xavier

  • 12-16-2008 04:42 PM In reply to

    Are you sure you need Outlook Properties, or are you talking about Active Directory properties?  I think maybe because you look at Outlook properties to get this info, you are referring to it by that name?  If you want to automatically retrieve any and all Active Directory information relevant to an individual and are using MOSS 2007, then you can easily do it through the UserProfileService without writing any code.  Department is one of the main values available via this web service.  If this is what you mean, then let me know - it's easy and awesome.  If not, then pardon the interruption.  :)

  • 12-16-2008 11:20 PM In reply to

    Both are good!

     We are using MOSS 2007 and Infopath 2007.

    Can you tell me how to use this UserProfileService?

    Is there something to install? Because as I work for multiple client, the less we modify their environment (with installations, etc...) the better it is!

     

    Thank you so much!

     

    Xavier

  • 12-17-2008 07:51 AM In reply to

    No, there is no install - this web service is exposed by SharePoint out-of-the-box.  You just have to know how to use it.  Since I can't take credit for figuring out how to leverage this amazing resources without code, I will link you to the place I went to learn it:

    http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

    Go through those steps and see if it works for you.  I use it on every form and absolutely love it, so I can probably help you with tips and tricks if you struggle.

  • 12-18-2008 02:06 AM In reply to

    Awesome! It works! 

    Thank you very much!

     

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.