Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

eMail Submit button with mailto: based on form data

Not applicable
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
Niall_O_Donovan
Level 10
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
Not applicable
Thank you - this worked out well. I was able to do what I needed.



/cw
Not applicable
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
pguerett
Level 10
Level 10
If you post your email I will send you a sample that shows how to modify the email address based on a dropdown selection.
Not applicable
Hey thanks for this Paul. My email address is tim.grigor@gmail.com



Thanks again

Tim
sbryner
Level 1
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
Not applicable
could you also send to me. i keep getting null.... thanks



Emtesenair@liberty.edu
Not applicable
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.
pguerett
Level 10
Level 10
That would be a mil client issue. We simply ask the mail client to create a mail message (through an API).
Not applicable
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?
pguerett
Level 10
Level 10
Don't think that would be the issue.
Not applicable
Paul, could you send that to me as well? Thanks!



Davecox2@mac.com
maginoo
Level 1
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!