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

An error occured while sending the email

Community Beginner ,
Aug 15, 2023 Aug 15, 2023

Hi! I have below script. I need to email currently opened PDF to a defined email address but I get the return error in my code "An error occured while sending the email". Any thoughts appreciated! Thank you.

 

// Prompt the user for an email address
var emailAddress = app.response({
cQuestion: "Enter recipient's email address:",
cTitle: "Email Document",
cDefault: "recipient@example.com"
});

// Get the currently opened document
var currentDoc = app.activeDocs[0];

// Get the file path of the current document
var filePath = currentDoc.path;

//Convert filePath to a clickable path
var link = "<a href=\"file:///" + filePath + "\">" + "</a>";

// Check if a document is currently open
if (currentDoc) {
// Create a new email object
var mailObj = {
cTo: emailAddress,
cSubject: "For Your Review and Signature",
cMsg: "Please review and sign the document(s) located at:\n" +link,
cCc: "", // Add CC recipients if needed
cBcc: "", // Add BCC recipients if needed
};

// Try sending the email
try {
app.mailMsg(mailObj);
// Show success dialog
app.alert("Email sent successfully.", 3); // 3 represents an Information icon
} catch (e) {
console.println("Error sending email: " + e);
app.alert("An error occurred while sending the email.", 1); // 1 represents an Error icon
}
} else {
app.alert("No document open.", 1);
}

 

TOPICS
JavaScript , PDF
180
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
no replies

Have something to add?

Join the conversation