Expand my Community achievements bar.

Adding field data to subject line and body of email

Avatar

Former Community Member

HI

I have created a form that can be submitted by e-mail. I would like the data entered into the form to populate the subject line and body of the email but have no idea of how to script this. I would be grateful if someone could have a look at the form and see how I can achieve this.

For example

subject line: Travel and accommodation form [Name] [EventName] [StartDate]

Body:

Please open the attached travel and accommodation for for [Name] who will be attending [EventName] on the [Start Date]

Here is the code for my button:

<field name="Submit" y="219.075mm" x="139.7mm" w="34.925mm" h="6mm">
            <ui>
               <button/>
            </ui>
            <font typeface="Myriad Pro"/>
            <caption>
               <value>
                  <text>Submit</text>
               </value>
               <para vAlign="middle" hAlign="center"/>
               <font typeface="Myriad Pro"/>
            </caption>
            <border hand="right">
               <?templateDesigner StyleID apbx2?>
               <edge stroke="raised"/>
               <fill>
                  <color value="212,208,200"/>
               </fill>
            </border>
            <bind match="none"/>
            <event activity="click">
               <submit format="pdf" textEncoding="UTF-16" target=mailto:myaddress@test.com xdpContent="pdf datasets xfdf"/>
            </event>
         </field>


Please excuse my ignorance as not competent with XML so any help would be gratefully received. Have already tried some methods posted on here already but not helped.

3 Replies

Avatar

Level 4

Use the old way, this is, create a regular button and on the click event use something like this:

var oDoc = event.target;

oDoc.mailDoc({
bUI: true,
cTo: "aa@bb.cc",
cCC: "11@22.33",
cSubject: "TEXT " + field.rawValue + " more text",
cMsg: "PDF IN ATTACH."
});

Avatar

Former Community Member

Hi,

Thanks for your help. I understand the code but do not understand how it fits in with the code - as the code for regular button is as follows:

</field>
         <field name="Button1" y="219.075mm" x="142.875mm" w="28.575mm" h="6mm">
            <ui>
               <button/>
            </ui>
            <font typeface="Myriad Pro"/>
            <caption>
               <value>
                  <text>Button</text>
               </value>
               <para vAlign="middle" hAlign="center"/>
               <font typeface="Myriad Pro"/>
            </caption>
            <border hand="right">
               <?templateDesigner StyleID apbx2?>
               <edge stroke="raised"/>
               <fill>
                  <color value="212,208,200"/>
               </fill>
            </border>
            <bind match="none"/>
         </field>


Or if I chose a regular button and then choose "submit" as it's function I have

</field>
         <field name="Button1" y="219.075mm" x="139.7mm" w="34.925mm" h="6mm">
            <ui>
               <button/>
            </ui>
            <font typeface="Myriad Pro"/>
            <caption>
               <value>
                  <text>Button</text>
               </value>
               <para vAlign="middle" hAlign="center"/>
               <font typeface="Myriad Pro"/>
            </caption>
            <border hand="right">
               <?templateDesigner StyleID apbx2?>
               <edge stroke="raised"/>
               <fill>
                  <color value="212,208,200"/>
               </fill>
            </border>
            <bind match="none"/>
            <event activity="click">
               <submit format="pdf" textEncoding="UTF-16" xdpContent="pdf datasets xfdf"/>
            </event>
         </field>


Thanks again

Avatar

Level 4

Put it in the Click event of a Button with the control type set to regular.