Skip to main content
Participating Frequently
August 8, 2023
Question

How to attach embedded file (excel) with PDf form to email

  • August 8, 2023
  • 2 replies
  • 1302 views

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

    This topic has been closed for replies.

    2 replies

    try67
    Community Expert
    Community Expert
    August 8, 2023

    Where did you get this code from? AFAIK, there's no "getStream" method of the doc object, nor an aAttachments parameter of the mailDoc method.

     

    It also contains other errors, such as:

    this.extractPages(10, 11); // Extract pages 10 and 11

    This will extract pages 11-12, not 10-11.

     

    To the best of my knowledge, this is not possible with a script. But if the Excel file is attached to the PDF then it should be submitted with it.

    Participating Frequently
    August 8, 2023

    Hi, yes the excel is embeded in the file. User needs to fill the excel and then submit the submit button which should then extracts the pdf pages and the excel. How best do you think i can achieve this? The idea is to attach the file only when the checbox is activated, else it only attachs the pdf.

     

    Thanks

    Participating Frequently
    August 8, 2023

    I don't believe that's possible. Also, extracting pages won't work if the file is used in Reader. All of your users will have to have Adobe Acrobat.


    oh! I see. What is the best way to attach certain pages of a pdf form to an email which can also be used in Reader? 

    kglad
    Community Expert
    Community Expert
    August 8, 2023

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post if it helps you get responses.



    <"moved from using the community">