Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Aug 08, 2023 Aug 08, 2023

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

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2023 Aug 08, 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">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2023 Aug 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2023 Aug 08, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2023 Aug 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2023 Aug 08, 2023

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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2023 Aug 08, 2023
LATEST

The only way to do something like that in Reader is if those pages were spawned from a Template page in advance. In that case they could be deleted before the file is submitted.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines