Difference between revisions of "EmailTemplate class"

From Catglobe Wiki
Jump to: navigation, search
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{CGscriptClass_Template |Name=Dictionary |Description=The dictionary object |Constructors= {{CGscriptConstructors_Template|Description=Create a new dictionary with non-argument.}} {{CGscriptConstructors_Template|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} |Description=Create new dictionary with the specified key-value pairs.}} {{CGscriptConstructors_Template|Parameters= {{CGscriptParameters_Template|Type=array|Name=keys|Description=keys arrayConstant|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=values|Description=values arrayConstant}} |Description=Create new dictionary with the specified keys and values.}} |Methods= {{CGscriptMethods_Template|ReturnType=bool|Name=Add|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=Add with specific key|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=value|Description=Add with specific value}} |Description=Adds the specified key and value to the dictionary.}} {{CGscriptMethods_Template|ReturnType=bool|Name=Add|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=Add with specific key|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=value|Description=Add with specific value}} |Description=Adds the specified key and value to the dictionary.}} {{CGscriptMethods_Template|ReturnType=Empty|Name=Add|Parameters= {{CGscriptParameters_Template|Type=Dictionary|Name=src|Description=Source of keys and values to add}} |Description=Adds the all keys and values from src to current.}} {{CGscriptMethods_Template|ReturnType=Empty|Name=Clear|Description=Remove all keys and values from the dictionary.}} {{CGscriptMethods_Template|ReturnType=bool|Name=ContainsKey|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=Check with specific key}} |Description=Determines whether the dictionary contains the specified key.}} {{CGscriptMethods_Template|ReturnType=bool|Name=ContainsKey|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=Check with specific key}} |Description=Determines whether the dictionary contains the specified key.}} {{CGscriptMethods_Template|ReturnType=bool|Name=ContainsValue|Parameters= {{CGscriptParameters_Template|Type=object|Name=value|Description=Add with specific value}} |Description=Determines whether the dictionary contains the specified value.}} {{CGscriptMethods_Template|ReturnType=object|Name=this[] { get; }|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=The key used to lookup the value.}} |Description=Get an item based on a key.}} {{CGscriptMethods_Template|ReturnType=object|Name=this[] { get; }|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=The key used to lookup the value.}} |Description=Get an item based on a key.}} {{CGscriptMethods_Template|ReturnType=object|Name=Remove|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=Check with specific key}} |Description=Remove the value with the specified key from the dictionary.}} {{CGscriptMethods_Template|ReturnType=object|Name=Remove|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=Remove with specific key}} |Description=Remove the value with the specified key from the dictionary.}} {{CGscriptMethods_Template|ReturnType=Empty|Name=this[] { set; }|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=The key used to lookup the value.|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=value|Description=The value to set.}} |Description=Set an item based on a key and a value.}} {{CGscriptMethods_Template|ReturnType=Empty|Name=this[] { set; }|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=The key used to lookup the value.|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=value|Description=The value to set.}} |Description=Set an item based on a key and a value.}} {{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}} {{CGscriptMethods_Template|ReturnType=object|Name=TryGetValue|Parameters= {{CGscriptParameters_Template|Type=string|Name=key|Description=Remove with specific key}} |Description=Gets the value associated with the specified key.}} {{CGscriptMethods_Template|ReturnType=object|Name=TryGetValue|Parameters= {{CGscriptParameters_Template|Type=int|Name=key|Description=Remove with specific key}} |Description=Gets the value associated with the specified key.}} |Properties= {{CGscriptProperties_Template|ReturnType=int|Name=Count|HasGetter=1|Description=Gets the number of key/value pairs contained in the dictionary.}} {{CGscriptProperties_Template|ReturnType=array|Name=Keys|HasGetter=1|Description=Gets a list of keys.}} {{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}} {{CGscriptProperties_Template|ReturnType=array|Name=SortedKeys|HasGetter=1|Description=Gets a list of keys sorted by current collation.}} {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} {{CGscriptProperties_Template|ReturnType=array|Name=Values|HasGetter=1|Description=Gets a list of values.}} }}
+
{{CGscriptClass_Template
 +
|Name=<nowiki>EmailTemplate</nowiki>
 +
|Description=<nowiki>Represents an email account.</nowiki>
 +
|InheritsFrom=object|Constructors=
 +
{{CGscriptConstructors_Template|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>resourceId</nowiki>|Description=<nowiki>The resource id of existing template</nowiki>}}
 +
|Description=<nowiki>Instanciate an existing template</nowiki>}}
 +
{{CGscriptConstructors_Template|Parameters=
 +
{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of the new template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentResourceId</nowiki>|Description=<nowiki>The resource id of existing template</nowiki>}}
 +
|Description=<nowiki>Create a new template</nowiki>}}
 +
|Methods=
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save the Email template</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SendTestLinks</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentResourceId</nowiki>|Description=<nowiki>Which resource to store the emails under</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>emails</nowiki>|Description=<nowiki>List of emails to send test mail to</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>backupUserResourceId</nowiki>|Description=<nowiki>In case an email doesnt have a user, revert to showing this users info in the mail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=EmailAccount|Name=<nowiki>from</nowiki>|Description=<nowiki>From address</nowiki>}}
 +
|Description=<nowiki>Merge emails and send as test</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 +
|Properties=
 +
{{CGscriptProperties_Template|ReturnType=DateTime|Name=<nowiki>CreatedDate</nowiki>|HasGetter=1|Description=<nowiki>Get the time of creation.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>MessageDefaultLanguage</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the default language mail body.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=DateTime|Name=<nowiki>ModifiedDate</nowiki>|HasGetter=1|Description=<nowiki>Get the time of last modification.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>ParentResourceId</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get the resource id.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>PrimaryKey</nowiki>|HasGetter=1|Description=<nowiki>Get the primary id for use in ancient functions.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>ResourceId</nowiki>|HasGetter=1|Description=<nowiki>Get the resource id.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ResourceName</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get the resource name.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>SubjectDefaultLanguage</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/Set the default language subject.</nowiki>}}
 +
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
 +
|StaticMethods=
 +
{{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>EmailTemplate_getAllFromParent</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentResourceId</nowiki>|Description=<nowiki>The resource id of existing template</nowiki>}}
 +
|Description=<nowiki>Find all mail template that are children on the given resource</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>EmailTemplate_send</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailId</nowiki>|Description=<nowiki>Id of mail template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTest</nowiki>|Description=<nowiki>Send as test mail or not</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>email</nowiki>|Description=<nowiki>Email address of receiver</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>alias</nowiki>|Description=<nowiki>Alias of receiver</nowiki>}}
 +
|Description=<nowiki>Send mail from current QAS context</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>EmailTemplate_send</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailId</nowiki>|Description=<nowiki>Id of mail template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTest</nowiki>|Description=<nowiki>Send as test mail or not</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>email</nowiki>|Description=<nowiki>Email address of receiver</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>alias</nowiki>|Description=<nowiki>Alias of receiver</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=number|Name=<nowiki>parentId</nowiki>|Description=<nowiki>Id of resource that contain these mail in communication tab after sending. Set empty to use questionnaire of current QAS context</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>from</nowiki>|Description=<nowiki>From email address. Set empty to use default mail of parent</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Function|Name=<nowiki>custom</nowiki>|Description=<nowiki>A callback function use to override mail content before send. Set empty to ignore</nowiki>}}
 +
|Description=<nowiki>Send mail</nowiki>}}
 +
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>EmailTemplate_send</nowiki>|Parameters=
 +
{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailId</nowiki>|Description=<nowiki>Id of mail template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTest</nowiki>|Description=<nowiki>Send as test mail or not</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>email</nowiki>|Description=<nowiki>Email address of receiver</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>alias</nowiki>|Description=<nowiki>Alias of receiver</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>ccmails</nowiki>|Description=<nowiki>CC mails, string array</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>bccmails</nowiki>|Description=<nowiki>BCC mails, string array</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=number|Name=<nowiki>parentId</nowiki>|Description=<nowiki>Id of resource that contain these mail in communication tab after sending. Set empty to use questionnaire of current QAS context</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>from</nowiki>|Description=<nowiki>From email address. Set empty to use default mail of parent</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Function|Name=<nowiki>custom</nowiki>|Description=<nowiki>A callback function use to override mail content before send. Set empty to ignore</nowiki>}}
 +
|Description=<nowiki>Send multiple mails. Notice CC/BCC mails are not available if isTest = true</nowiki>}}
 +
}}
 +
 
 +
=== Examples ===
 +
 
 +
<source lang="javascript">
 +
EmailTemplate email = new EmailTemplate(15537524);
 +
number parentRsId = email.ParentResourceId;
 +
 
 +
EmailTemplate emailNew = new EmailTemplate("BinhTESTNEW", parentRsId);
 +
emailNew.SubjectDefaultLanguage = "newSub";
 +
emailNew.MessageDefaultLanguage = "Newbody";
 +
emailNew.Save();
 +
 
 +
 
 +
</source>
 +
 
 +
Result:
 +
 
 +
[[File:Emailtemplate new.jpg]]
 +
<br><source lang="javascript">
 +
//Ex for using SendTestLinks
 +
EmailTemplate et = new EmailTemplate (15550048);
 +
EmailAccount acc = new EmailAccount("antest");
 +
array toEmails = {
 +
"a1@maysunshine.vn",
 +
"a2@maysunshine.vn",
 +
"a3@maysunshine.vn",
 +
"a4@maysunshine.vn"
 +
};
 +
et.SendTestLinks(15548961, toEmails, 15548957, acc);
 +
//if have no user on system map with the above email address, info of user 15548957 will be shown on the mail
 +
</source>

Latest revision as of 10:30, 25 April 2022

EmailTemplate



Represents an email account.

Parent class

Inherits from object

Constructors

  • (int resourceId "The resource id of existing template") - Instanciate an existing template
  • (string name "Name of the new template", int parentResourceId "The resource id of existing template") - Create a new template

Methods

  • Empty Save() - Save the Email template
  • Empty SendTestLinks(int parentResourceId "Which resource to store the emails under", array emails "List of emails to send test mail to", int backupUserResourceId "In case an email doesnt have a user, revert to showing this users info in the mail", EmailAccount from "From address") - Merge emails and send as test
  • (From object) string ToString() - The string representation of the object.

Properties

  • DateTime CreatedDate { get; } - Get the time of creation.
  • string MessageDefaultLanguage { get; set; } - Get/Set the default language mail body.
  • DateTime ModifiedDate { get; } - Get the time of last modification.
  • string ObjectTypeName { get; } - The name of the type of object.
  • int ParentResourceId { get; set; } - Get the resource id.
  • int PrimaryKey { get; } - Get the primary id for use in ancient functions.
  • int ResourceId { get; } - Get the resource id.
  • string ResourceName { get; set; } - Get the resource name.
  • string SubjectDefaultLanguage { get; set; } - Get/Set the default language subject.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.

Static Methods

  • array EmailTemplate_getAllFromParent(int parentResourceId "The resource id of existing template") - Find all mail template that are children on the given resource
  • Empty EmailTemplate_send(int mailId "Id of mail template", bool isTest "Send as test mail or not", string email "Email address of receiver", string alias "Alias of receiver") - Send mail from current QAS context
  • Empty EmailTemplate_send(int mailId "Id of mail template", bool isTest "Send as test mail or not", string email "Email address of receiver", string alias "Alias of receiver", number parentId "Id of resource that contain these mail in communication tab after sending. Set empty to use questionnaire of current QAS context", string from "From email address. Set empty to use default mail of parent", Function custom "A callback function use to override mail content before send. Set empty to ignore") - Send mail
  • Empty EmailTemplate_send(int mailId "Id of mail template", bool isTest "Send as test mail or not", string email "Email address of receiver", string alias "Alias of receiver", array ccmails "CC mails, string array", array bccmails "BCC mails, string array", number parentId "Id of resource that contain these mail in communication tab after sending. Set empty to use questionnaire of current QAS context", string from "From email address. Set empty to use default mail of parent", Function custom "A callback function use to override mail content before send. Set empty to ignore") - Send multiple mails. Notice CC/BCC mails are not available if isTest = true

Examples

EmailTemplate email = new EmailTemplate(15537524);
number parentRsId = email.ParentResourceId;

EmailTemplate emailNew = new EmailTemplate("BinhTESTNEW", parentRsId);
emailNew.SubjectDefaultLanguage = "newSub";
emailNew.MessageDefaultLanguage = "Newbody";
emailNew.Save();

Result:

Emailtemplate new.jpg


//Ex for using SendTestLinks
EmailTemplate et = new EmailTemplate (15550048);
EmailAccount acc = new EmailAccount("antest");
array toEmails = {
 "a1@maysunshine.vn", 
 "a2@maysunshine.vn",
 "a3@maysunshine.vn",
 "a4@maysunshine.vn"
};
et.SendTestLinks(15548961, toEmails, 15548957, acc);
//if have no user on system map with the above email address, info of user 15548957 will be shown on the mail