(Realized I posted this in the wrong forum originally.)
I am trying to include field data in the body of an email, rather than just as an XML attachment. I've played with various bits of Javascript in the "click" event of a regular button but am failing miserably.
I am using something like this:
var cToAddr = "******@*******.com"; var cSubLine = "Form X-1 returned from client"; var cBody = "Prospect data is as follows:" + date + field1 + field2 + field3; event.target.mailForm({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody})
Or this:
var Comment = referredto.rawValue;
if (referredto.rawValue == null){ Comment = " "} else {Comment = referredto.rawValue};
event.target.submitForm({cURL:"mailto:XXXX@XXXX.com?subject=XXXX &body="+Comment+,"",cSubmitAs:"PDF",cCharset:"utf-8"});
Please help. I don't know any JS or coding so need the syntax to be spelled out pretty clearly.
Views
Replies
Total Likes
I've gotten this far and am just trying to get the body text working... nothing's showing up there yet.
var mail;
var address = "XXXX@XXXX.com";
var subfirstname = firstname.rawValue;
var sublastname = lastname.rawValue;
var sublocation = location.rawValue;
mail = "mailto:" + address + "?subject=" + "New Prospect: "+ subfirstname + " " + sublastname + " in " + sublocation;
Body = sublocation;
event.target.submitForm({cURL: mail, cMsg: Body, cSubmitAs: "PDF",cCharset: "utf-8"});
Views
Replies
Total Likes
Are you getting any errors reported? Assuming you are using Acrobat - hit Ctrl-J, the java console will come up. That is where javascript errors will be reported. I assume that location has a value.
You may want to use a view app.alert statements to see what the value of your variables are. The syntax is
app.alert("The variable sublocation is: " + location);
or you can test the value of the field directly like this:
app.alert("The field location has this value: " + location.rawValue);
Paul
Views
Replies
Total Likes
I was actually able to get it working myself, using the following:
var mail;
var address = "xxxx@xxxx.com";
var firstname = firstname.rawValue;
var lastname = lastname.rawValue;
var location = location.rawValue;
var date = date.rawValue
var email = email.rawValue;
var phone = phone.rawValue;
var company = company.rawValue;
var heardabout = heardabout.rawValue;
var reasonforcall = reasonforcall.rawValue;
var referredto = referredto.rawValue;
var notes = notes.rawValue
var subject = "New Prospect: "+ firstname + " " + lastname + " in " + location;
body = "Date: " + date + "\n" + "Last Name: " + lastname + "\n" + "First Name: " + firstname + "\n" + "Phone: " + phone
+ "\n" + "Email: " + email + "\n" + "Company: " + company + "\n" + "Location: " + location + "\n" + "Heard about us from: " + heardabout
+ "\n" + "Reason for call: " + reasonforcall + "\n" + "Referred to: " + referredto + "\n" + "\n" + "Notes: " + "\n" + notes;
mail = "mailto:" + address + "?subject=" + subject + "&body=" + body ;
event.target.submitForm({cURL: mail, cMsg: cBody, cSubmitAs: "PDF",cCharset: "utf-8"});
Views
Replies
Total Likes