Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

eMail Submit button with mailto: based on form data

Avatar

Former Community Member
Based on form data, I would like to have an email button that sends mail to the email address identified in the email field. Obviously this can change, how would one go about programming a button to send to email based on field data?



Thx...



/cw
21 Replies

Avatar

Level 10
Hi Chris,



Yes this can be easily done. I gathered the following solutions from various threads and so I am not claiming any originality here...



Set up a textfield "Email", with a tooltip telling users to separate email addresses with a ";".



Next set up a regular button with the following Javascript in the click event:



var email = xfa.resolveNode("form1.#subform.Email").rawValue;

var subject = "Specify your subject line here"



event.target.submitForm({cURL:"mailto: "+ email +"?subject=" + subject +"&body=You can also input some standard text to appear in the body of the email.",cSubmitAs:"PDF",cCharset:"utf-8"});



You might want to put an if statement that if the "Email" textfield is blank/null that an app.alert comes up informing the user to input at least one email address.



We took it a stage further on one of our forms. We set up three checkboxes with people's names who are regularly sent the form (nod and cc1 and cc2) and then a textfield "additional" for additional addresses.



Each checkbox had an associated Textfield (EM1_email, cc1_email, and cc2_email) that were invisible. Each checkbox had similar Javascript in the mouse up event:



if (this.rawValue == 0) {

EM1_email.rawValue = null;

}

else {

EM1_email.rawValue = "someone@company.ie;";

}



Then we set up another invisible textfield (Email) which had the following Formcalc in the calculate event:



if (nod.rawValue == 0 & cc1.rawValue == 0 & cc2.rawValue == 0) then

$ = null

else

$ = Concat(EM1_email, cc1_email, cc2_email, additional)

endif



This basically pulled the email addresses from the ticked checkboxes and the additional user inputted email addresses into one text field. From there the regular button with the script above send the email. This speeded up the process for regular reciptents.



If you search the forum for topics such as cURL:"mailto: you should see lots of other examples.



Good luck,



Niall

Avatar

Former Community Member
Thank you - this worked out well. I was able to do what I needed.



/cw

Avatar

Former Community Member
Hey would you be able to post an example of the whole code for this type of email form. I am reasonably inexperienced with this type of stuff but have been asked to put an email form with recipient choices onto a clients page. Could you please help.



Thanks

Tim

Avatar

Former Community Member
If you post your email I will send you a sample that shows how to modify the email address based on a dropdown selection.

Avatar

Former Community Member
Hey thanks for this Paul. My email address is tim.grigor@gmail.com



Thanks again

Tim

Avatar

Level 1
Hi Paul,



Could you send me your example as well?

sbryner@swinomishcasino.com



I'm looking for something similar and new to acrobat javascripting.



thanks,

sky

Avatar

Former Community Member
could you also send to me. i keep getting null.... thanks



Emtesenair@liberty.edu

Avatar

Level 1
thanks for the file. it helped.

Avatar

Former Community Member
Is it possible to have the email generate without the body being alter? I find your signature doesn't get added as a normal mailto.

Avatar

Former Community Member
That would be a mil client issue. We simply ask the mail client to create a mail message (through an API).

Avatar

Former Community Member
If I click on a mailto on a website my signature show but the mailto from the form does something different. Is it because I am asking the PDF be attached?

Avatar

Former Community Member
Paul, could you send that to me as well? Thanks!



Davecox2@mac.com

Avatar

Level 1

Hi Paul,

How come I cannot access your pdf attachment? I got an error

"You don't have permission to access /servlet/JiveServlet/download/3138108-50593/email_Options.pdf on this server."

Thanks!