These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

app.mailMsg problem

MMWilliams
Registered: Aug 23 2010
Posts: 16
Answered

Hi,
 
I have a pretty long piece of javascript that I'm trying to write to get an acrobat form to launch the body of an email. There may be a few places that I've made errors, but can't find them for the life of me. I've used a similar version of this script and everything ran beautifully that time...
 
I'm still pretty green at all this, so would love any and all help.
  
Here's my current script:
  
var to = this.getField("To");
 
var membershipstatusv = this.getField("Membership Status");
 
var grmembernumberv = this.getField("GR Member Number");
 
var numberofpeopleimpactedv = this.getField("Number of people impacted");
 
var namesofmembersv = this.getField("Names of members");
 
var countryv = this.getField("Country");
 
var cityv = this.getField("City");
 
var latitudev = this.getField("Latitude");
 
var longitudev = this.getField("Longitude");
 
var incidenttypev = this.getField("Incident Type");
 
var descriptionofissuev = this.getField("Description of Issue");
 
var Actionstakentodatev = this.getField("Actions Taken To Date");
 
var timev = this.getField("Time");
 
var opspersonreportingv = this.getField("Ops person reporting");
 
var subject = "New Incident Notification"
 
var emailBody = "";
emailBody += "NEW INCIDENT\r\n";
emailBody += "COMM WATCHSTANDER: " + opspersonreportingv.value + "\r\n";
emailBody += "\r\n";
emailBody += "MEMBERSHIP STATUS";
emailBody += membershipstatusv.value + "\r\n";
emailBody += corporateclientnamev.value + "\r\n";
emailBody += othermembershiptypev.value + "\r\n";
emailBody += “GR MEMBER NUMBER:” + grmembernumberv.value + "\r\n";
emailBody += “NUMBER OF PEOPLE IMPACTED:" + numberofpeopleimpactedv.value + "\r\n";
emailBody += “NAMES OF MEMBERS” namesofmembersv.value + "\r\n";
emailBody += "\r\n";
emailBody += "LOCATION OF INCIDENT";
emailBody += countryv.value + "\r\n";
emailBody += cityv.value + "\r\n";
emailBody += “LAT” + latitudev.value + “ LONG” + longitudev.value + "\r\n";
emailBody += "\r\n";
emailBody += "INCIDENT TYPE";
emailBody += incidenttypev.value + "\r\n";
emailBody += "\r\n";
emailBody += "DESCRIPTION OF ISSUE";
emailBody += descriptionofissuev.value + "\r\n";
emailBody += "\r\n";
emailBody += "ACTIONS TAKEN TO DATE";
emailBody += actionstakentodatev.value + "\r\n";
emailBody += "\r\n";
emailBody += "TIME:" + timev.value + "\r\n";
emailBody += "\r\n";
emailBody += "SITREPs";
emailBody += SITREPSv.value + "\r\n";
   
app.mailMsg({
 
bUI: true,
 
cTo: to.value,
 
cSubject: subject,
 
cMsg: emailBody
 
} );

MMWilliams
Registered: Aug 23 2010
Posts: 16
I found a few small errors and fixed them, but there is still some unknown errors:

var to = this.getField("To");

var membershipstatusretv = this.getField("Membership Status RET");

var membershipstatusffsv = this.getField("Membership Status FFS");
var membershipstatuscorpv = this.getField("Membership Status CORP");
var membershipstatusotherv = this.getField("Membership Status OTHER");
var corporateclientnamev = this.getField("Corporate Client Name");
var othermembershiptypev = this.getField("Other Membership Type");

var grmembernumberv = this.getField("GR Member Number");

var numberofpeopleimpactedv = this.getField("Number of people impacted");

var namesofmembersv = this.getField("Names of members");

var countryv = this.getField("Country");

var cityv = this.getField("City");

var latitudev = this.getField("Latitude");

var longitudev = this.getField("Longitude");

var incidenttypev = this.getField("Incident Type");

var descriptionofissuev = this.getField("Description of Issue");

var Actionstakentodatev = this.getField("Actions Taken To Date");

var timev = this.getField("Time");

var opspersonreportingv = this.getField("Ops person reporting");

var subject = "New Incident Notification"

var emailBody = "";
emailBody += "NEW INCIDENT\r\n";
emailBody += "COMM WATCHSTANDER: " + opspersonreportingv.value + "\r\n";
emailBody += "\r\n";
emailBody += "MEMBERSHIP STATUS";
emailBody += membershipstatusretv.value + "\r\n";

emailBody += membershipstatusffsv.value + "\r\n";
emailBody += membershipstatuscorpv.value + "\r\n";
emailBody += membershipstatusotherv.value + "\r\n";
emailBody += corporateclientnamev.value + "\r\n";
emailBody += othermembershiptypev.value + "\r\n";
emailBody += “GR MEMBER NUMBER:” + grmembernumberv.value + "\r\n";
emailBody += “NUMBER OF PEOPLE IMPACTED:" + numberofpeopleimpactedv.value + "\r\n";
emailBody += “NAMES OF MEMBERS” namesofmembersv.value + "\r\n";
emailBody += "\r\n";
emailBody += "LOCATION OF INCIDENT";
emailBody += countryv.value + "\r\n";
emailBody += cityv.value + "\r\n";
emailBody += “LAT” + latitudev.value + “ LONG” + longitudev.value + "\r\n";
emailBody += "\r\n";
emailBody += "INCIDENT TYPE";
emailBody += incidenttypev.value + "\r\n";
emailBody += "\r\n";
emailBody += "DESCRIPTION OF ISSUE";
emailBody += descriptionofissuev.value + "\r\n";
emailBody += "\r\n";
emailBody += "ACTIONS TAKEN TO DATE";
emailBody += actionstakentodatev.value + "\r\n";
emailBody += "\r\n";
emailBody += "TIME:" + timev.value + "\r\n";
emailBody += "\r\n";
emailBody += "SITREPs";
emailBody += SITREPSv.value + "\r\n";



app.mailMsg({

bUI: true,

cTo: to.value,

cSubject: subject,

cMsg: emailBody

} );


George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You haven't explained the problem you're experiencing. I'm assuming it doesn't work, but do you get any error messages, either pop-ups or in the JavaScript console? The more information you can provide, the better.
MMWilliams
Registered: Aug 23 2010
Posts: 16
Thanks George.

The script was not generating the email. I tested each line with the mail script and nailed down a few errors and just got the form to launch the email body. In order to get it to work, I had to remove a few lines that were giving me an error message in the edit javascript editor window saying "missing ; before statement" "48: at line 49"

I readded the line in question so the code is now:

var to = this.getField("To");

var membershipstatusretv = this.getField("Membership Status RET");
var membershipstatusffsv = this.getField("Membership Status FFS");
var membershipstatuscorpv = this.getField("Membership Status CORP");
var membershipstatusotherv = this.getField("Membership Status OTHER");
var corporateclientnamev = this.getField("Corporate Client Name");
var othermembershiptypev = this.getField("Other Membership type");
var grmembernumberv = this.getField("GR Member Number");
var numberofpeopleimpactedv = this.getField("Number of people impacted");
var namesofmembersv = this.getField("Names of members");

var countryv = this.getField("Country");
var cityv = this.getField("City");
var latitudev = this.getField("Latitude");
var longitudev = this.getField("Longitude");
var incidenttypev = this.getField("Incident Type");
var descriptionofissuev = this.getField("Description of Issue");
var actionstakentodatev = this.getField("Actions Taken To Date");


var opspersonreportingv = this.getField("Ops person reporting");

var subject = "New Incident Notification";
var timev = this.getField("Time");

var emailBody = "";
emailBody += "NEW INCIDENT\r\n";

emailBody += "COMM WATCHSTANDER: " + opspersonreportingv.value + "\r\n";

emailBody += "\r\n";





emailBody += "MEMBERSHIP STATUS";

emailBody += membershipstatusretv.value + "\r\n";

emailBody += membershipstatusffsv.value + "\r\n";

emailBody += membershipstatuscorpv.value + "\r\n";

emailBody += membershipstatusotherv.value + "\r\n";

emailBody += corporateclientnamev.value + "\r\n";

emailBody += othermembershiptypev.value + "\r\n";

emailBody += “GR MEMBER NUMBER:” + grmembernumberv.value + "\r\n" ;

emailBody += "\r\n";





emailBody += "LOCATION OF INCIDENT";

emailBody += countryv.value + "\r\n";

emailBody += cityv.value + "\r\n";

emailBody += "\r\n";





emailBody += "INCIDENT TYPE";

emailBody += incidenttypev.value + "\r\n";

emailBody += "\r\n";





emailBody += "DESCRIPTION OF ISSUE";

emailBody += descriptionofissuev.value + "\r\n";

emailBody += "\r\n";





emailBody += "ACTIONS TAKEN TO DATE";

emailBody += actionstakentodatev.value + "\r\n";

emailBody += "\r\n";





emailBody += "TIME:" + timev.value + "\r\n";

emailBody += "\r\n";





app.mailMsg({

bUI: true,

cTo: to.value,

cSubject: subject,

cMsg: emailBody

} );


Readding the line "emailBody += “GR MEMBER NUMBER:” + grmembernumberv.value + "\r\n" ;" now does not let me finalize the code to test.

Is that clear?

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
When I pasted your code, I got an error at the same line, and it's due to incorrect quotes around the "GR MEMBER NUMBER" string. Replace what's there with standard quotes.
MMWilliams
Registered: Aug 23 2010
Posts: 16
That's crazy. I'm not sure how the wrong quotes got in, but I swapped them out and it works like magic.

You're a hero again, George.

Thanks!!

Martha