Marc
02/27/2025, 2:24 PMCeligo AI
02/27/2025, 2:25 PMAI generated answer (using internal Slack threads):To create a script to send an email and dynamically retrieve a file from the File Cabinet based on the selected template, you can use SuiteScript's
N/email
and N/file
modules. Here's a basic example:
javascript
var email = require('N/email');
var file = require('N/file');
function sendEmailWithAttachment(fileId, recipientEmail) {
var myFile = file.load({
id: fileId // replace with your file id
});
email.send({
author: -5, // replace with your user id
recipients: recipientEmail,
subject: 'My Subject',
body: 'My Body',
attachments: [myFile]
});
}
In this script, the file.load
function is used to load the file from the File Cabinet using its ID. The loaded file is then attached to the email using the attachments
property of the email.send
function.
If you're getting an error saying the file ID cannot be found, even though the file exists in the File Cabinet, it could be due to several reasons:
1. The file ID you're using is incorrect. Make sure you're using the correct file ID. You can find the file ID by opening the file in the File Cabinet and checking the URL.
2. The file is not available without login. Make sure the file is set to be available without login.
3. The file is not in a public folder. Make sure the file is in a public folder in the File Cabinet.
4. You don't have the necessary permissions to access the file. Make sure your role has the necessary permissions to access the file.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
02/27/2025, 2:25 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83415848
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827400923
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823815346
Celigo AI
02/27/2025, 2:25 PM