Skip to main content
Participant
April 25, 2023
Question

JavaScript Code Issue: Unable to Attach CSV File to Email Using Adobe "Mail Doc" Feature

  • April 25, 2023
  • 2 replies
  • 1923 views

Hello Adobe Community,

I am currently working on a JavaScript code to retrieve all the fields and their corresponding values from a PDF form, convert them into a CSV file, and then attach the CSV file to an email using the "mail doc" feature. However, when I open the email, I am unable to see the attached CSV file, and in some cases, I am encountering an error message that says "security prevents access to this property or method."

I would appreciate any guidance or solutions from the community regarding this issue. Thank you in advance for your help.

Best regards,

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
April 25, 2023

This is not possible with a script. It can only attach the PDF document itself to an email it generates.

The CSV file can be attached to the PDF, though.

Legend
April 25, 2023

Please share the specific code - actually both, the code that gets the error message, and the code that doesn't, and seems to send the file. You needn't give all the details of how you fill in the CSV (but leave in the open/creation/closing/saving/whatever).

Participant
April 25, 2023
var fieldKeys = [];
var fieldValues = [];

for (var i = 0; i < this.numFields; i++) {
  var field = this.getField(this.getNthFieldName(i));
  fieldKeys.push(field.name);
  fieldValues.push(field.value);
}

var csvContent = fieldKeys.join(',') + '\n' + fieldValues.join(',');
this.createDataObject('output.csv', csvContent);
var attachment = this.getDataObjectContents('output.csv');
var email = "recipient@example.com";
var subject = "CSV file attachment";
var message = "Please find attached the CSV file.";

var mimeType = "text/csv";
var fileName = "output.csv";
this.mailDoc({bUI: true, cTo: email, cSubject: subject, cMsg: message, oAttach: attachment, cPath: mimeType, cSubmitAs: "PDF", cURL: fileName});i have created this script

 

try67
Community Expert
Community Expert
April 25, 2023

The mailDoc method doesn't have a cPath or a cURL parameters.