Javascript help with extract, saveAs, and maildoc
Hello, I am have been trying to create a javascript that when a button is clicked the document will extract saveAs and then email the document. I have had sucess extracting the page, saveing it with a filename from one of the form fields. However i am running into a issue mailing the newly saved document. I am using a trusted funtion script. I have reviewed the documentation out there however I just need a little help getting over the finish line. Here is what I have so far.
My Trusted script contained in a .js file named Myscripts that is located in my user folder.
var mySaveAs = app.trustedFunction(
function(oDoc,cPath,cFlName)
{
app.beginPriv();
// Ensure path has trailing "/"
cPath = cPath.replace(/([^/])$/, "$1/");
try{
oDoc.saveAs(cPath + cFlName);
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
}
);Here is my Button Script:
/*********** belongs to: AcroForm:Button1:Annot1:MouseUp:Action1 ***********/
var outputPath = "/c/temp";
var newFileName = "storedtickets " + this.getField("FORM_NAME").valueAsString + ".pdf";
var newDoc = mySaveAs(this.extractPages(0), outputPath, newFileName);
newDoc.mailDoc();Everything works except for attaching the extracted page to the email. With this script i am getting the error "TypeError: newDoc is undefined
5:Field:Mouse Up"
If I change the newDoc.mailDoc() to this.mailDoc() or mailDoc() it is just attaching the orgnial file not the extracted page. Any help would be greatly apprecatied.
