Difference between revisions of "BulkMail class"
(Replaced content with "[In progress]") (Tag: Replaced) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{CGscriptClass_Template | |
+ | |Name=<nowiki>BulkMail</nowiki> | ||
+ | |Description=<nowiki>Represents a bulkMail.</nowiki> | ||
+ | |InheritsFrom=object|Constructors= | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>bulkMailId</nowiki>|Description=<nowiki>Id of bulkMail</nowiki>}} | ||
+ | |Description=<nowiki>Load existing bulkMail</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentId</nowiki>|Description=<nowiki>Parent of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailTemplateId</nowiki>|Description=<nowiki>Id of mail template</nowiki>}} | ||
+ | |Description=<nowiki>Create bulkMail</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentId</nowiki>|Description=<nowiki>Parent of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailTemplateId</nowiki>|Description=<nowiki>Id of mail template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>resourceTemplateId</nowiki>|Description=<nowiki>Id of bulkMail resource template</nowiki>}} | ||
+ | |Description=<nowiki>Create bulkMail</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>parentId</nowiki>|Description=<nowiki>Parent of bulkMail</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>mailTemplateId</nowiki>|Description=<nowiki>Id of mail template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>resourceTemplateId</nowiki>|Description=<nowiki>Id of bulkMail resource template</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=EmailAccount|Name=<nowiki>fromEmail</nowiki>|Description=<nowiki>from email account</nowiki>}} | ||
+ | |Description=<nowiki>Create bulkMail</nowiki>}} | ||
+ | |Methods= | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save bulkMail</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>Send</nowiki>|Description=<nowiki>Send bulkMail with default options. MaxToSend = -1, Test = false.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>SendBulkMail</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>maxToSend</nowiki>|Description=<nowiki>Max mail send, default is maximum (-1)</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTest</nowiki>|Description=<nowiki>Is test link, default is real</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isSyncronious</nowiki>|Description=<nowiki>Type of send, default is not syncronious</nowiki>}} | ||
+ | |Description=<nowiki>Send bulkMail with full options</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>SendSyncronious</nowiki>|Description=<nowiki>Send bulkMail syncronious with default options. MaxToSend = -1, Test = false.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>SendWithCallback</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>callback</nowiki>|Description=<nowiki>Callback function</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>maxToSend</nowiki>|Description=<nowiki>Max mail send, default maximum</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTest</nowiki>|Description=<nowiki>Is test link, default is real</nowiki>}} | ||
+ | |Description=<nowiki>Send bulkMail with callback, it is syncronious</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>SendWithSchedule</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=CatTaskSchedule|Name=<nowiki>schedule</nowiki>|Description=<nowiki>Use the given schedule instance to send the mails</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>maxToSend</nowiki>|Description=<nowiki>Max mail send, default maximum</nowiki>}} | ||
+ | |Description=<nowiki>Send bulkMail with schedule</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetGroups</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Array of ints|Name=<nowiki>groupIds</nowiki>|Description=<nowiki>Array of group id</nowiki>}} | ||
+ | |Description=<nowiki>Set groups to bulkMail</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetGroupsToBeRebuilt</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Array of ints|Name=<nowiki>groupIds</nowiki>|Description=<nowiki>Array of group id</nowiki>}} | ||
+ | |Description=<nowiki>Set groups to be rebuilt to bulkMail</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>SetUsers</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Array of ints|Name=<nowiki>userIds</nowiki>|Description=<nowiki>Array of user id</nowiki>}} | ||
+ | |Description=<nowiki>Set users to bulkMail</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}} | ||
+ | |Properties= | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>DependantBulkMail</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Dependant of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>DependantSelectedHistories</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>selected history of the dependant bulkMail, return array of BulkMailHistory object</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>DependantSendToCompleted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Dependant bulkMail completed status</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>DependantSendToNotStarted</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Dependant bulkMail not start status</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>DependantSendToPartly</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Dependant bulkMail partly status</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=EmailAccount|Name=<nowiki>From</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>EmailAccount used to send</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=Array of ints|Name=<nowiki>GroupIds</nowiki>|HasGetter=1|Description=<nowiki>GroupIds of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=Array of ints|Name=<nowiki>GroupRebuildIds</nowiki>|HasGetter=1|Description=<nowiki>GroupIds to be rebuild before sent bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>History</nowiki>|HasGetter=1|Description=<nowiki>History of the bulkMail, return array of BulkMailHistory object</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Id</nowiki>|HasGetter=1|Description=<nowiki>Id of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>MailTemplateId</nowiki>|HasGetter=1|Description=<nowiki>MailTemplateId Id of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Name of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>NoInOutQueue</nowiki>|HasGetter=1|Description=<nowiki>Number of mail in queue</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>NoOfSent</nowiki>|HasGetter=1|Description=<nowiki>Number of mail sent</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>ParentId</nowiki>|HasGetter=1|Description=<nowiki>Parent Id of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Priority</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Priority of the bulkMail (0: Bulkmail_Priority_Normal, 1: Bulkmail_Priority_Low, 2: Bulkmail_Priority_High)</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>ResourceTemplateId</nowiki>|HasGetter=1|Description=<nowiki>ResourceTemplateId Id of the bulkMail</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=Array of ints|Name=<nowiki>UserIds</nowiki>|HasGetter=1|Description=<nowiki>UserIds of the bulkMail</nowiki>}} | ||
+ | }} | ||
+ | |||
+ | === <span style="color:#DF8621">'''Examples'''</span> === | ||
+ | <source lang="javascript"> | ||
+ | //*** create Bulkmail***// | ||
+ | |||
+ | string bulkmailName = "test"; | ||
+ | number parentId = 17145420; | ||
+ | number mailTemplateId = 17146733; | ||
+ | number resourceTemplateId = 2079; | ||
+ | EmailAccount fromEmail = new EmailAccount ("panel"); | ||
+ | BulkMail bm = new BulkMail (bulkmailName, parentId , mailTemplateId, resourceTemplateId, fromEmail); | ||
+ | //bm.SetUsers ({....}); | ||
+ | //bm.SetGroups({...}); | ||
+ | //bm.SetGroupsToBeRebuilt({...}); | ||
+ | bm.Save(); | ||
+ | </source> | ||
+ | <source lang="javascript"> | ||
+ | //*** create Dependent Bulkmail***// | ||
+ | |||
+ | string bulkmailName = "test"; | ||
+ | number parentId = 17145420; | ||
+ | number mailTemplateId = 17146733; | ||
+ | number resourceTemplateId = 17146732;//resource template with dependent true | ||
+ | EmailAccount fromEmail = new EmailAccount ("panel"); | ||
+ | BulkMail bm = new BulkMail (bulkmailName, parentId , mailTemplateId, resourceTemplateId, fromEmail); | ||
+ | number dependantBulkmailId = 17146766; | ||
+ | bm.DependantBulkMail = dependantBulkmailId; | ||
+ | bm.DependantSelectedHistories = new BulkMail (dependantBulkmailId).History; | ||
+ | bm.DependantSendToNotStarted = true; | ||
+ | bm.DependantSendToPartly = true; | ||
+ | bm.DependantSendToCompleted = false; | ||
+ | bm.Save(); | ||
+ | </source> | ||
+ | |||
+ | <source lang="javascript"> | ||
+ | //*** send Bulkmail ***// | ||
+ | |||
+ | new BulkMail(bulkmailId).Send(); //Returns CatTask instance id of the sending | ||
+ | </source> | ||
+ | |||
+ | <source lang="javascript"> | ||
+ | //*** Send Bulkmail syncronious ***// | ||
+ | |||
+ | new BulkMail(bulkmailId).SendSyncronious(); //Return number of mails being sent | ||
+ | </source> | ||
+ | |||
+ | <source lang="javascript"> | ||
+ | //*** SendBulkMaild ***// | ||
+ | |||
+ | new BulkMail(bulkmailId).SendBulkMail(maxToSend , isTest, isSyncronious);//Send bulkMail with full options | ||
+ | </source> | ||
+ | |||
+ | <source lang="javascript"> | ||
+ | //*** SendWithCallback***// | ||
+ | |||
+ | new BulkMail(bulkmailId).SendWithCallback(function(number nrSending) { | ||
+ | bool hasEnough = false; | ||
+ | if (!hasEnough) throw (nrSending); | ||
+ | }, maxToSend, isTest); | ||
+ | |||
+ | </source> | ||
+ | <source lang="javascript"> | ||
+ | //*** SendWithSchedule ***// | ||
+ | |||
+ | new BulkMail(bulkmailId).SendWithSchedule(new CatTaskSpecificTimeSchedule(new DateTime()), maxToSend); | ||
+ | </source> |
Latest revision as of 09:17, 12 May 2022
BulkMail
Represents a bulkMail.
Parent class
Inherits from object
Constructors
- (int bulkMailId "Id of bulkMail") - Load existing bulkMail
- (string name "Name of bulkMail", int parentId "Parent of bulkMail", int mailTemplateId "Id of mail template") - Create bulkMail
- (string name "Name of bulkMail", int parentId "Parent of bulkMail", int mailTemplateId "Id of mail template", int resourceTemplateId "Id of bulkMail resource template") - Create bulkMail
- (string name "Name of bulkMail", int parentId "Parent of bulkMail", int mailTemplateId "Id of mail template", int resourceTemplateId "Id of bulkMail resource template", EmailAccount fromEmail "from email account") - Create bulkMail
Methods
- Empty Save() - Save bulkMail
- int Send() - Send bulkMail with default options. MaxToSend = -1, Test = false.
- int SendBulkMail(int maxToSend "Max mail send, default is maximum (-1)", bool isTest "Is test link, default is real", bool isSyncronious "Type of send, default is not syncronious") - Send bulkMail with full options
- int SendSyncronious() - Send bulkMail syncronious with default options. MaxToSend = -1, Test = false.
- int SendWithCallback(Function callback "Callback function", int maxToSend "Max mail send, default maximum", bool isTest "Is test link, default is real") - Send bulkMail with callback, it is syncronious
- int SendWithSchedule(CatTaskSchedule schedule "Use the given schedule instance to send the mails", int maxToSend "Max mail send, default maximum") - Send bulkMail with schedule
- Empty SetGroups(Array of int groupIds "Array of group id") - Set groups to bulkMail
- Empty SetGroupsToBeRebuilt(Array of int groupIds "Array of group id") - Set groups to be rebuilt to bulkMail
- Empty SetUsers(Array of int userIds "Array of user id") - Set users to bulkMail
- (From object) string ToString() - The string representation of the object.
Properties
- int DependantBulkMail { get; set; } - Dependant of the bulkMail
- array DependantSelectedHistories { get; set; } - selected history of the dependant bulkMail, return array of BulkMailHistory object
- bool DependantSendToCompleted { get; set; } - Dependant bulkMail completed status
- bool DependantSendToNotStarted { get; set; } - Dependant bulkMail not start status
- bool DependantSendToPartly { get; set; } - Dependant bulkMail partly status
- EmailAccount From { get; set; } - EmailAccount used to send
- Array of int GroupIds { get; } - GroupIds of the bulkMail
- Array of int GroupRebuildIds { get; } - GroupIds to be rebuild before sent bulkMail
- array History { get; } - History of the bulkMail, return array of BulkMailHistory object
- int Id { get; } - Id of the bulkMail
- int MailTemplateId { get; } - MailTemplateId Id of the bulkMail
- string Name { get; set; } - Name of the bulkMail
- int NoInOutQueue { get; } - Number of mail in queue
- int NoOfSent { get; } - Number of mail sent
- string ObjectTypeName { get; } - The name of the type of object.
- int ParentId { get; } - Parent Id of the bulkMail
- int Priority { get; set; } - Priority of the bulkMail (0: Bulkmail_Priority_Normal, 1: Bulkmail_Priority_Low, 2: Bulkmail_Priority_High)
- int ResourceTemplateId { get; } - ResourceTemplateId Id of the bulkMail
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
- Array of int UserIds { get; } - UserIds of the bulkMail
Examples
//*** create Bulkmail***//
string bulkmailName = "test";
number parentId = 17145420;
number mailTemplateId = 17146733;
number resourceTemplateId = 2079;
EmailAccount fromEmail = new EmailAccount ("panel");
BulkMail bm = new BulkMail (bulkmailName, parentId , mailTemplateId, resourceTemplateId, fromEmail);
//bm.SetUsers ({....});
//bm.SetGroups({...});
//bm.SetGroupsToBeRebuilt({...});
bm.Save();
//*** create Dependent Bulkmail***//
string bulkmailName = "test";
number parentId = 17145420;
number mailTemplateId = 17146733;
number resourceTemplateId = 17146732;//resource template with dependent true
EmailAccount fromEmail = new EmailAccount ("panel");
BulkMail bm = new BulkMail (bulkmailName, parentId , mailTemplateId, resourceTemplateId, fromEmail);
number dependantBulkmailId = 17146766;
bm.DependantBulkMail = dependantBulkmailId;
bm.DependantSelectedHistories = new BulkMail (dependantBulkmailId).History;
bm.DependantSendToNotStarted = true;
bm.DependantSendToPartly = true;
bm.DependantSendToCompleted = false;
bm.Save();
//*** send Bulkmail ***//
new BulkMail(bulkmailId).Send(); //Returns CatTask instance id of the sending
//*** Send Bulkmail syncronious ***//
new BulkMail(bulkmailId).SendSyncronious(); //Return number of mails being sent
//*** SendBulkMaild ***//
new BulkMail(bulkmailId).SendBulkMail(maxToSend , isTest, isSyncronious);//Send bulkMail with full options
//*** SendWithCallback***//
new BulkMail(bulkmailId).SendWithCallback(function(number nrSending) {
bool hasEnough = false;
if (!hasEnough) throw (nrSending);
}, maxToSend, isTest);
//*** SendWithSchedule ***//
new BulkMail(bulkmailId).SendWithSchedule(new CatTaskSpecificTimeSchedule(new DateTime()), maxToSend);