Anybody have any working example of `mergeEmail` w...
# suitescript
a
Anybody have any working example of
mergeEmail
with SS 2.0 specifically merging a transaction PDF with email template?
a
Copy code
var emailMergeResult = render.mergeEmail({
	templateId: emailTemplateId,
	entity: {
		type: 'customer',
		id: parseInt(customerId)
	},
	recipient: null,
	supportCaseId: null,
	transactionId: parseInt(transactionId),
	customRecord: null
});
You must render the pdf before that.
Copy code
var transactionFile = render.transaction({
	entityId: parseInt(transactionId),
	printMode: render.PrintMode.PDF,
	inCustLocale: true
});
After that, you bring it all together and send via email.
Copy code
var emailSubject = emailMergeResult.subject;
var emailBody = emailMergeResult.body;
email.send({
	author: emailAuthor,
	recipients: emailRecipients,
	subject: emailSubject,
	body: emailBody,
	attachments: [transactionFile],
	relatedRecords: {
		transactionId: parseInt(transactionId)
	}
});