Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to submit to email with specific fields in subject line?

New Here ,
Mar 16, 2018 Mar 16, 2018

I've got a pdf created with a submit button. it works, but I would like to collect information in a field of the PDF and include it in the subject line of the email.

Ex: I need to collect the Users name field to be included in the subject line of the email.

Is this possible?

TOPICS
PDF forms
22.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 16, 2018 Mar 16, 2018

OK, then remove the Submit Form command you added to the button and add a Run a JavaScript command instead, with this code:

var targetEmail = "me@server.com";

var subjectLine = this.documentFileName + " " + this.getField("First").valueAsString + " " + this.getField("MI").valueAsString + " " + this.getField("Last").valueAsString;

this.mailDoc({cTo: targetEmail, cSubject: subjectLine});

Of course, change the target email address in the first line to the actual one you want to use.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 07, 2023 Nov 07, 2023

Thank you, I'll try there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 07, 2019 Dec 07, 2019

Ah. Thank you! I was putting them all in separate quoatation marks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2020 Apr 27, 2020

I have tried the same above per instruction(I am submitting the whole sheet) and it does nothing once I have modified the script with my field names. I do have required fields for all 3 fields in my code below:

 

var targetEmail = " bryanc@xxx.com;?cc=jamiem@xxx.com;heathers@xxx.com";

var subjectLine = this.documentFileName + " " + this.getField("Unit Number").valueAsString + " " + this.getField("Ordered by").valueAsString + " " + this.getField("Order Date").valueAsString;

var body = "Please fill out form completely and with as much information as you can. Thanks.\nThis is a new line of text.";

this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body}):

 

What am I missing?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2020 Apr 27, 2020

The CC address(es) needs to be specified using the cCc parameter. Also, drop the space at the start of the targetEmail variable. And check the JS Console for errors once you run the code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2020 Apr 27, 2020

Thanks. That was it!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 07, 2023 Nov 07, 2023

Hi Try67,

 

I have tried a few combinations and the javascript does not work for me.

 

var targetEmail = "XXX@sever.com";

var subjectLine = this.documentFileName + " " + this.getField("Change No.").valueAsString + " " + this.getField("Permit Holder (Supervisor of the Work").valueAsString + " " + this.getField("Last").valueAsString;

var body = "The permit has been signed off.\nThis is a new line of text.";

this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});

 

What am I missing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2023 Nov 07, 2023

Check the JavaScript console for errors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 21, 2024 Feb 21, 2024

Hi Try67 (i know your name from previous encounters, but I am not sure I should use it here.

I have adapted the basic script in this string to get the proper subjectline based on my form. I can also add a body line, but I would like it to appear before the actual form, rather than at the end of the body of the email. (In this case the message is "Here is my application. Thank you." 

 

See images. Is there a way to do this? Thanks, Stuart

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 21, 2024 Feb 21, 2024

Actually, I still have a bit of a problem because when I open the pdf, it immediately gives me a box to send an email before I have actually completed the form....How do I fix that?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2024 Feb 21, 2024

Try this:

va targetEmail = "pacifictransportationassoc@gmail.com";
var subjectline = this.documentFileName + " " + this.getField("PTA Membership Application Renewal form").valueAsString + " " + this.getField("Name 1").valueAsString;
var body = "Here is my completed application. Thank you";
this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body});

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 21, 2024 Feb 21, 2024

hmm, I get an error message...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 23, 2024 Feb 23, 2024

This script works to add the form to the outgoing email and adds the proper subject line.  I guess I can dispense with the message in the body.  But my problem is this:  I open the document the first thing that happens is a cue to send email, before the form opens to allow people to fill it in.

 

This will be distributed to people and they should not confront this confusing email message until they have seen and completed the form. How can I eliminate that first email box and open the form directly?

 

 

//------------------------------------------------------------- //-----------------Do not edit the XML tags-------------------- //------------------------------------------------------------- //<Document-Level> //<ACRO_source>Email Response</ACRO_source> //<ACRO_script> /*********** belongs to: Document-Level:Email Response ***********/ var targetEmail = "pacifictransportationassoc@gmail.com"; var subjectLine = "PTA Membership Application Renewal from " + this.getField("Name 1").valueAsString; var body = "Enter the message body here.\nThis is a new line of text.";

this.mailDoc({cTo: targetEmail, cSubject: subjectLine, cMsg: body}); //</ACRO_script> //</Document-Level>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2024 Feb 23, 2024

You need to place the script somewhere else, then. What do you want to trigger it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2024 Feb 23, 2024

PS. Do NOT edit the code via the Edit All JavaScripts window! You can seriously mess up your file if you do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 23, 2024 Feb 23, 2024

I'm sorry, I don't know enough about this to understand your answer. I created a document java script, but then I don't know how to apply this script to a button...I see no way to select this particular script. ANd I am not even sure this it the right way to do it.

It might be better if you can point me to some sort of tutorial, rather than try to go back and forth with this, given my limited knowledge.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 23, 2024 Feb 23, 2024

I want them to click on the link associated with the line that says "email this completed form...."

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2024 Feb 23, 2024

Remove the code from the doc-level script and place it under the Action of your Link object. It's that simple.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 23, 2024 Feb 23, 2024
LATEST

Worked!...thanks.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines