Skip to main content
Inspiring
May 10, 2023
解決済み

Email Javascript Submit Button

  • May 10, 2023
  • 返信数 5.
  • 6189 ビュー

I would like to to pull a name from a form field on my forms and place it where (add name from a form field here) in the script below. The script works perfectly as is, I would just like to add the name to each section. Can someone please help? Thanks

 

this.mailDoc({ cTo: "joeblow@myemail.com",


cSubject: "My Form for (add NAME from a form field here)",cMsg: "Please see the attached form in reference to (add NAME from a form field here) ."

 

});

 

このトピックへの返信は締め切られました。
解決に役立った回答 JR Boulay

Try this:

 

var str1 = this.getField("FirstName").valueAsString;
var str2 = this.getField("MiddleName").valueAsString;
var str3 = this.getField("LastName").valueAsString;
var sMsg = "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of " + str1 + " " + str2 + " " + str3 + ". If you have any questions, please feel free to contact my office. Thank you!"
var sSubject = "My Form";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

返信数 5

JR Boulay
Community Expert
JR BoulayCommunity Expert解決!
Community Expert
May 17, 2023

Try this:

 

var str1 = this.getField("FirstName").valueAsString;
var str2 = this.getField("MiddleName").valueAsString;
var str3 = this.getField("LastName").valueAsString;
var sMsg = "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of " + str1 + " " + str2 + " " + str3 + ". If you have any questions, please feel free to contact my office. Thank you!"
var sSubject = "My Form";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

Acrobate du PDF, InDesigner et Photoshopographe
Charles5C81作成者
Inspiring
May 17, 2023

Thank you for your response again. For some reason it will not pull the form fields into the email. I have the fields labeled exactly like in the code.

Charles5C81作成者
Inspiring
May 17, 2023

And the console has no errors. 

Charles5C81作成者
Inspiring
May 16, 2023

This is the javascript that I would actually like to have if you could help me figure out how to pull the First, Middle, and Last name from the form fields in the pdf form. Each name has it's own field and are titled (FirstName) (MiddleName) (LastName). For some reason, the script will not recogzine the field name. This script works perfectly except it will not pull the fields into the message. Thank you!

 

this.mailDoc({ cTo: "joeblow@myemail.com",


cSubject: "Justice of the Peace Inquest Summary Report/Autopsy Authorization",cMsg: "Please see the attached Inquest Summary Report/Autopsy Authorization in reference to the death of (First Name) (MiddleName) (LastName). If you have any questions, please feel free to contact my office. Thank you!"

 

});

JR Boulay
Community Expert
Community Expert
May 12, 2023

The Console says your made a typo in the field's name.

JavaScript is case sensitive.

Acrobate du PDF, InDesigner et Photoshopographe
Charles5C81作成者
Inspiring
May 12, 2023

Thank you for your response. I will see if that works

Charles5C81作成者
Inspiring
May 16, 2023

I double checked the spelling of the form field name and still getting the same response in the console. It's still not recognizing the form field name. Thanks for any help with this.

Legend
May 11, 2023

1. Where exactly did you enter this code, and how did you run it?

2. Was there anything in the JavaScript console?

Charles5C81作成者
Inspiring
May 11, 2023

I entered the code in the action tab with javascript. 

Legend
May 11, 2023

And... question 2 please. 

JR Boulay
Community Expert
Community Expert
May 11, 2023

Try this, after adjusting the field name:

 

var sName = this.getField("name").valueAsString;
var sSubject = "My Form for " + sName;
var sMsg = "Please see the attached form in reference to " + sName + ".";
this.mailDoc({ cTo: "joeblow@myemail.com", cSubject: sSubject ,cMsg: sMsg});

Acrobate du PDF, InDesigner et Photoshopographe
Charles5C81作成者
Inspiring
May 11, 2023

Thanks for your reply. I entered the code and replaced "name" with my form field name but nothing happened.