EmailTemplate send

From Catglobe Wiki
Jump to: navigation, search


EmailTemplate_send

send mail by an existing mail template

Syntax

EmailTemplate_send(mailTemplateId, isTest, toEmail, alias ) - Send mail from current QAS context

EmailTemplate_send(mailTemplateId, isTest, toEmail, alias, parentId, fromEmail, callbackMethod) - Send mail from parent

EmailTemplate_send(mailTemplateId, isTest, toEmail, alias, ccEmails, bccEmails, parentId, fromEmail, callbackMethod) - Send multiple mails. Notice CC/BCC mails are not available if isTest = true

Arguments

mailTemplateId: number - is RId of the mail template

isTest: bool - Send as test mail or not

toEmail: string - is email address of receiver

alias: string - is alias of receiver

ccEmails: array - are CC email address

bccEmails: array - are BCC email address

parentId: number - is RId of resource that contain these mail in communication tab after sending. Set empty to use questionnaire of current QAS context

fromEmail: string - From email address. Set empty to use default mail of parent

callbackMethod : function(subject, message) - use to update mail subject, content before send. Set empty to ignore

Return type

Empty

Examples

number mailTemplateId = 17148149;
bool isTest = false;
string toEmail = "email@...";
string alias = "Alias";
//array ccEmails = {"email@...", ...};
//array bccEmails = {"email@...", ...};
number parentId = 17148159; //empty to use questionnaire of current QAS context
string fromEmail = "panel@..."; //empty to use default EmailAccount of parent
object callbackMethod = function (string subject, string message){//empty to ignore
	subject = "Test" + getRandomNumber(0,10); 
	return {subject, message};
};
//EmailTemplate_send(mailTemplateId, isTest, toEmail, alias);
EmailTemplate_send(mailTemplateId, isTest, toEmail, alias, parentId, fromEmail, callbackMethod);
//EmailTemplate_send(mailTemplateId, isTest, toEmail, alias, ccEmails, bccEmails, parentId, fromEmail, callbackMethod);