How to attach embedded file (excel) with PDf form to email
Hallo guys,
I want to attach an embedded excel file into an email dialog as attachment along with the form. My code as follows doesn't seem to work
var mehrfachAnmeldungCheckbox = this.getField("Mehrfachanmeldung");
var anforderungTextField = this.getField("Anforderung");
var textFieldAB = this.getField("textfield (A+B)");
try {
var newDoc = this.extractPages(10, 11); // Extract pages 10 and 11
var emailOptions = {
cTo: "test@test.com", // Recipient email
cSubject: "Anforderung - Angebot für Firma " + anforderungTextField.value + " " + textFieldAB.value,
cMsg: "Body message of the email",
cBcc: "bcc@test.com", // BCC email
oDoc: newDoc // Attach the new document to the email
};
if (mehrfachAnmeldungCheckbox.value === "Ja") {
// Attach the embedded Excel file using its file name
var excelAttachmentStream = this.getStream("Excel_fuer_Mehrfachanmeldung_PDF_DV_UK.xlsx");
if (excelAttachmentStream) {
emailOptions.aAttachments = [{
cAttachmentName: "Excel_fuer_Mehrfachanmeldung_PDF_DV_UK.xlsx",
oAttachment: excelAttachmentStream
}];
}
}
// Send the email with the attached document and optional Excel attachment
this.mailDoc(emailOptions);
newDoc.closeDoc(true); // Close the new document
} catch (e) {
// Handle the email sending error if needed
}
Can anyone help out?
Thanks
