Dynamic Subject in my email - InfoPath Dev
in

InfoPath Dev

Dynamic Subject in my email

Last post 08-16-2006 10:33 AM by Taffman. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 06-27-2006 07:31 AM

    • davers
    • Not Ranked
    • Joined on 06-26-2006
    • USA
    • Posts 15

    Dynamic Subject in my email

    Ok...I've gotten my form to work so far...:-) I'm hooked into a Web Services...my default view will return the information I need. I created an "Email" view that the form will switch to using rules before it creates the e-mail using this code:

    var oEnvelope = XDocument.View.Window.MailEnvelope;
    oEnvelope.To = "[email protected]";
    oEnvelope.Subject = "Subject";
    oEnvelope.Visible = true;

    What I'd like is for the Subject to be filled in dynamically using both "hard coded" text, and parameters from the form. So, for instance, I'd like the subject to say:

    Employee information for 'DYNAMIC PART GOES HERE'

    So "Employee information for " will always be in the subject, and it would take the name from my form and put it after that. I've seen how to do that when I use "Submit"...but I can't seem to get it to work in my code. I've tried:

    concat("Employee information for ", CDSID)

    But alas...it isn't meant to be...how can I do this in my code??

    Thanks for any help!!

    Dave
  • 06-27-2006 11:04 AM In reply to

    Re: Dynamic Subject in my email

    Hi Dave, it looks like you are mixing languages (XPath and JavaScript). concat() is for XPath. You would just need to do something like:

    oEnvelope.Subject = "Employee information for " + XDocument.DOM.selectSingleNode("XPath_To_Field").text;
  • 06-27-2006 11:26 AM In reply to

    • davers
    • Not Ranked
    • Joined on 06-26-2006
    • USA
    • Posts 15

    Re: Dynamic Subject in my email

    OH MY GOSH!!!! IT WORKED!!! I owe you a few beers!!
    Seriously...thank you thank you thank you...I've been working on this for 2 days straight...

    Dave
  • 06-27-2006 11:30 AM In reply to

    Re: Dynamic Subject in my email

    Glad to help out. Its just a matter of keeping your languages straight.
  • 08-16-2006 07:08 AM In reply to

    Re: Dynamic Subject in my email

    This has proven very useful to me, thanks. Only question I have is that the entire xlm form gets sent as an attachment. Any way to stop the form being attached?
  • 08-16-2006 09:41 AM In reply to

    Re: Dynamic Subject in my email

    Ah. There isn't a way to do this in InfoPath 2003. But in InfoPath 2007 you are able to fine tune the email settings to only send the view, attach the XML, and even attach the XSN for simple (restricted trust) forms!
    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-16-2006 10:09 AM In reply to

    Re: Dynamic Subject in my email

    Ok many thanks..
  • 08-16-2006 10:23 AM In reply to

    Re: Dynamic Subject in my email

    You're welcome. This was a good opportunity to explain the new mail features. :)
    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-16-2006 10:33 AM In reply to

    Re: Dynamic Subject in my email

    One final question if I may. If I use the standard submit to email feature, the form will not allow an email submission if there is an error on the form, i.e. missing mandatory data, which is good.

    When using the above code behind a button, the code allows an incomplete form to be sent via email. Any way to enforce the mandatory data check when using the above code?
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.