Cycling through a list box for sending emails - InfoPath Dev
in

InfoPath Dev

Cycling through a list box for sending emails

Last post 01-12-2006 08:36 PM by Matt Faus. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-12-2006 12:27 AM

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Cycling through a list box for sending emails

    Hi there!

    I'm sorry for this easy question, but I don't know java script and not much about infopath and I'm trying to get a quick solution.

    I created an infopath document and I want to send an email to all members of a sharepoint contact list on submission to a sharepoint form library.

    I created a "submit" butten and I got the email address from all contact list members into a hidden list box (by creating a new data source).

    The final question is know, how do I cycle through the list box and append the items to a ";" seperated string in order to send an email?

    Thanks for any help!
  • 01-12-2006 01:11 AM In reply to

    Re: Cycling through a list box for sending emails

    Hi Delu,
    Welcome on board!
    You dont need a hidden listbox binded to the datasource for this, you can directly loop through the datasource for doing this.

    Search for "selectNodes" keyword in the forum you will find lot of posts which specify how to loop through the the reapeating nodes.

    Agni
    InfoPath Dev India
  • 01-12-2006 02:50 AM In reply to

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Re: Cycling through a list box for sending emails

    Hi Agni.

    Wow, I'm impressed about your quick answer :-)

    Thanks a lot. I switched to C# because I'm more familiar with it and I also want to create some entries at the share point web parts, which seems to be very easy this way (but I just started).

    I will search for cycling through the data source with c#. Thanks :-)
  • 01-12-2006 07:31 PM In reply to

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Re: Cycling through a list box for sending emails

    Hi Agni.

    It turns out it is not so easy.
    Right now, I have the following code:


    DataObject contacts = thisXDocument.DataObjects["Contacts"];
    contacts.Query();
    DOMNodeList contactList = contacts.DOM.selectNodes("//*");
    if ((contactList != null))
    {
    for(int i = 0; i< contactList.length; i++)
    {
    thisXDocument.UI.Alert(contactList.text);
    }

    }


    I get the right number of pop-ups, but they are all empty.
    Why?

    For the select statement: How do I know the XML Hirarchy of the data source?

    Another thing I can't figure out is why can't I cycle through the list with a "foreach (DOMNode .." Statement? I always get an exception.
  • 01-12-2006 08:32 PM In reply to

    • delu
    • Not Ranked
    • Joined on 01-12-2006
    • Posts 13

    Re: Cycling through a list box for sending emails

    Just before lunch, I finally managed how to do this :-)

  • 01-12-2006 08:36 PM In reply to

    Re: Cycling through a list box for sending emails

    Try this code (I think it is a little cleaner than a for loop):

    DOMNodeList contactList = contacts.DOM.selectNodes("//YOUR_EMAIL_GROUP");

    IMSXMLNode next; // I don't know C# good, but declare a node here (what is the data type?)

    while( next = contactList.nextNode() )
    {
    thisXDocument.UI.Alert( next.selectSingleNode( "my:emailNode" ).text );

    }


    Hope this helps - sorry if the syntax is a little off, I'm not quite fluent in C#.

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.