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
publicEMailMessageSendEnhanced(strEMailToAddress:string,strEMailSubject:string,strEMailContent:string,strContentType:string=this.strDefaultContentType,arrMimeAttachment:MimeAttachment[]=this.arrDefaultMimeAttachment):boolean{
letobjEmailMessage: EmailMessage=newEmailMessage();
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();
returntrue;
}catch (objException){
returnfalse;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
