To use this function add it to the class library file named OrchestratorService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorService.ts
Functions: EMailMessageSendEnhanced
Description: The following is the script to send an e-mail
public EMailMessageSendEnhanced(strEMailToAddress: string, strEMailSubject: string, strEMailContent: string, strContentType: string = this.strDefaultContentType, arrMimeAttachment: MimeAttachment[] = this.arrDefaultMimeAttachment): boolean {
let objEmailMessage: EmailMessage = new EmailMessage();
objEmailMessage.smtpHost = this.strSMTPHostFQDN;
objEmailMessage.smtpPort = this.intSMTPHostPort;
objEmailMessage.fromName = this.strEMailFromName;
objEmailMessage.fromAddress = this.strEMailFromAddress;
objEmailMessage.toAddress = strEMailToAddress;
objEmailMessage.subject = strEMailSubject;
objEmailMessage.addMimePart(strEMailContent, strContentType);
arrMimeAttachment.forEach((objMimeAttachment: MimeAttachment) => {
this.objLogger.info(`Adding attachment: ${objMimeAttachment.name} with contentType: ${objMimeAttachment.mimeType}.`);
objEmailMessage.addMimePart(objMimeAttachment, null);
});
this.objLogger.info(`sending mail to host: ${objEmailMessage.smtpHost}:${objEmailMessage.smtpPort}, from:${objEmailMessage.fromAddress}, to:${objEmailMessage.toAddress} contentType:${strContentType}.`);
try {
objEmailMessage.sendMessage();
return true;
} catch (objException) {
return false;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
