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

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

New Here ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

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

Views

14.8K

Translate

Translate

Report

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

correct answers 1 Correct answer

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.

Votes

Translate

Translate
Community Expert ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Thanks, but I don't know much about scripts. I read through it but can't figure out how to, or where to add that to the submit button properties.

The Submit button automatically adds the file name to the Subject Line of the email. I need to pull three fields: First, MI, Last and add it to the end of that.

I also would like to remove "Form Returned" from the subject . . . . . I'm getting close to having a great process in place . . . .

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Are you submitting the whole form, or just the form data? Are you relying on the validation of the required fields?

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

I want to submit the entire form as a PDF. This is a form that multiple people will be completing. I wanted to collect the Users name in the subject line so when it arrived it would be easier to keep up with. The email is actually sending this form into ServiceNow and creating tickets. User names will be invaluable for us in tracking the tickets.

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

And the answer to my other question?...

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Sorry,

No validation, just whatever is typed into the name field to be added to the subject line

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Cool!

by golly, I think that did it!

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Looks like that removed the body text as well. Do I add "var body = what i want in the body" ??

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Almost. Use this:

var targetEmail = "me@server.com";

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

var body = "Enter the message body here.\nThis is a new line of text.";

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

Votes

Translate

Translate

Report

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 ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

You're the BEST!!!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Is there a way to send to multiple email addresses using this script? 

Votes

Translate

Translate

Report

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 ,
Dec 07, 2019 Dec 07, 2019

Copy link to clipboard

Copied

Sure. Just change this line:

var targetEmail = "me@server.com";

To something like this:

var targetEmail = "me@server.com;john@server.com;jane@server.com";

Votes

Translate

Translate

Report

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 ,
Aug 10, 2023 Aug 10, 2023

Copy link to clipboard

Copied

For line 3: var body = "Enter the message body here.\nThis is a new line of text.";

How can I change this to include "this.getField" to show specific fields in the body of the email? 

Votes

Translate

Translate

Report

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 ,
Aug 10, 2023 Aug 10, 2023

Copy link to clipboard

Copied

Like this:

 

var body = "Enter the message body here.\nThis is a new line of text\nSent by: " + this.getField("Name").valueAsString;

Votes

Translate

Translate

Report

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 ,
Aug 10, 2023 Aug 10, 2023

Copy link to clipboard

Copied

Thank you! What if perhaps I needed to add a secondary line to the body of the email, something like this?

 

var body = "New Sales Order.\nPlease enter and prepare to ship\nOrdered By: " + this.getField("Ship To").valueAsString " + this.getField(“Other Comments or Special Instructions”).valueAsString;

Votes

Translate

Translate

Report

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 ,
Aug 10, 2023 Aug 10, 2023

Copy link to clipboard

Copied

You just need to add the "\n" where you want the line-break to appear. For example:

var body = "New Sales Order.\nPlease enter and prepare to ship\nOrdered By: " + this.getField("Ship To").valueAsString " + "\n" + this.getField("Other Comments or Special Instructions").valueAsString;

 

You need to make sure your code only has straight-codes, though, not curly ones like your example above.

Do NOT use Word as a code editor. Only use a plain-text editor, like Notepad++.

 

Votes

Translate

Translate

Report

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 ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Thank you so much for your answer. It worked for me. Is there any way to automatically rename the attached file as well?

Votes

Translate

Translate

Report

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 ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Only if you can install a script file on the machine of each user who will be using it.

Votes

Translate

Translate

Report

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
Contributor ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Hi @try67,

I'm wondering if there's a way to include the entire code within the "mailto:" line? My concern is that I have required fields, and I'd like to prevent the form from being submitted when those fields are empty.

 

Thank you 

 

Votes

Translate

Translate

Report

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

No, but you can use a script to perform that validation yourself, before submitting the file.

I've posted code that does that to this forum multiple times. Search "validateRequiredFields".

Votes

Translate

Translate

Report

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
Contributor ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Thank you

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Would this work the same way for an Adobe sign web form? I'd like my web form when submitted and an email is received that the subject line includes the name of the document and a name field from the form to easily identify who filled out the web form.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I doubt it, as such forms have little to no support for scripts, but you can try asking in the Acrobat Sign forum.

Votes

Translate

Translate

Report

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