Highlighted

eMail Submit button with mailto: based on form data

Avatar

Guest

04-02-2009

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

Replies

Highlighted

Niall_O_Donovan

05-02-2009

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
Highlighted

Avatar

Guest

16-03-2009

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
Highlighted

pguerett

16-03-2009

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

sbryner

19-03-2009

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