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?
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.
Copy link to clipboard
Copied
Yes, using a script. See: https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address
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 . . . .
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?
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.
Copy link to clipboard
Copied
And the answer to my other question?...
Copy link to clipboard
Copied
Sorry,
No validation, just whatever is typed into the name field to be added to the subject line
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.
Copy link to clipboard
Copied
Cool!
by golly, I think that did it!
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" ??
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});
Copy link to clipboard
Copied
You're the BEST!!!
Copy link to clipboard
Copied
Is there a way to send to multiple email addresses using this script?
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";
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?
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;
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;
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++.
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?
Copy link to clipboard
Copied
Only if you can install a script file on the machine of each user who will be using it.
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
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".
Copy link to clipboard
Copied
Thank you
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.
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.