MailEnvelope / populating Subject with form data - InfoPath Dev
in

InfoPath Dev

MailEnvelope / populating Subject with form data

Last post 05-10-2012 08:54 AM by sezdar. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-07-2007 06:51 AM

    • ablinn
    • Not Ranked
    • Joined on 03-07-2007
    • Posts 2

    MailEnvelope / populating Subject with form data

    I am using MailEnvelope to embed an InfoPath form into an e-mail message. (There are people outside my network who need access to the form.)

    When the mail form opens, I want to automatically populate the Subject with two fields from the InfoPath form. Is this possible?

    Here's my current code:

    function CTRL44_5::OnClick(eventObj)
    {
    createEmail();
    }
    function createEmail()
    {
    var xmlContributors = XDocument.DOM.selectNodes("my:template");
    var xmlContributor;
    var rgRecipients = new Array();
    while (xmlContributor = xmlContributors.nextNode()
    )
    rgRecipients.push(getNodeValue(xmlContributor.selectSingleNode("my:To")));
    try
    {
    var oEnvelope = XDocument.View.Window.MailEnvelope;
    oEnvelope.To = "[email protected]";
    //This is where I need help. The titles of the two form fields are listed below. (In my form, they're both text boxes.) When I try running anything with the name of a field, I get an "undefined" error. I'm not a coder by trade so please err on the side of extra detail.
    oEnvelope.Subject = FORREVIEW.text + DocumentTitle.text;
    oEnvelope.Visible = true;
    }
    catch (ex)
    {
    XDocument.UI.Alert(ex.description);
    }
    }
  • 03-07-2007 10:51 PM In reply to

    Re: MailEnvelope / populating Subject with form data

    Question. Are FORREVIEW and DocumentTitle the names of your controls within your Infopath form ?

    If yes then in code you have to use something like this:

    IXMLDOMNode myForReview = XDocument.Dom.SelectSingleNode("my:myFields/my:FORREVIEW")

    and then in your subject you can use myForReview.text
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-12-2007 09:03 AM In reply to

    • ablinn
    • Not Ranked
    • Joined on 03-07-2007
    • Posts 2

    Re: MailEnvelope / populating Subject with form data

    Thanks nukkumatti.

    I tried the approach you suggested but I couldn't get it to work. It's very possible that it's because I am not knowledgable enough with coding. I also tried several other approaches that I read online on various sites, and I couldn't get any of them to work either. However, I found an approach in the InfoPath 2003 SDK documentation that seemed to work great. Using the Source property, I was able to populate the Subject field of the e-mail message with node values from my form.

    I also tried to understand the purpose of each line, and after testing the code I was able to eliminate several lines.

    function CreateMailEnvelope::OnClick(eventObj)
    {
    var oEnvelope = Application.ActiveWindow.MailEnvelope;
    oEnvelope.To = "DL name or e-mail address A; DL name or e-mail address B";
    oEnvelope.CC = "DL name or e-mail address C";
    oEnvelope.Visible = true;
    oEnvelope.Subject = eventObj.Source.selectSingleNode("//my:ForReview").text + eventObj.Source.selectSingleNode("//my:DocumentTitle").text;

    var objView;
    objView = XDocument.Mail;
    XDocument.View.SwitchView("mail");
    }


  • 05-10-2012 08:54 AM In reply to

    • sezdar
    • Not Ranked
    • Joined on 05-10-2012
    • Posts 1

    Re: MailEnvelope / populating Subject with form data

    in relation to this - I was wondering if there is a way to make the subject field on the MailEnvelope Read only.

    I have my users submitting the forms however I would like them to stop amended the Subject field on the emails. (sorry if its a simple answer but I am not well adept at coding)

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