Skip to main content
gdc_vip_support
Participating Frequently
March 16, 2018
Answered

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

  • March 16, 2018
  • 2 replies
  • 24219 views

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?

This topic has been closed for replies.
Correct answer try67

Sorry,

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


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.

2 replies

michaelr51760947
Participant
December 7, 2019

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

Participant
April 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?

 

try67
Community Expert
Community Expert
April 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.

try67
Community Expert
Community Expert
March 16, 2018
gdc_vip_support
Participating Frequently
March 16, 2018

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 . . . .

gdc_vip_support
Participating Frequently
March 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.


Cool!

by golly, I think that did it!