AxMmServer.CampaignManager
In C#, VB.Net, C++ and other compiled languages the namespace for most classes is AXMMCFGLib instead of AxMmServer. For interpreted languages like VBScript, JavaScript or Powershell it is AxMmServer.
| Property | Type | Read/Write | Description |
| LastError | Integer | Read | Result code of the last called method on this object |
| LastErrorDescription | String | Read | Result description of the last called method on this object |
| LogFile | String | Read/Write | Specify a logfile that is used when running a campaign |
| Count | Integer | Read | The number of messages generated from this campaign |
| BatchID | Integer | Read | The batch ID for this campaign |
| CustomSmsMessage | String | Read/Write | Overrides the SMS message |
| CustomPlainTextMessage | String | Read/Write | Overrides the plain text e-mail body |
| CustomHtmlMessage | String | Read/Write | Overrides the HTML e-mail body |
| CustomSubject | String | Read/Write | Overrides the e-mail subject |
| Method | Description |
| Run | Immediately run the specified campaign |
| Load | Load a campaign from the datasource into memory |
| StartBatch | Start a batch to run a campaign |
| StopBatch | Stop the current campaign batch |
| CreateNextMessage | Create the next message from a campaign |
LastError property
Returns the result code of the last called method on this object.
To find the error description please use LastErrorDescription.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0)
{
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
LastErrorDescription property
Describes the result of the last method called on this object.
The description will be empty on success.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0)
{
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
LogFile property
Contains the path of the logfile that should be used when running a campaign.
This property is empty by default.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.LogFile = "Logfile.txt"
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.LogFile = "Logfile.txt";
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0)
{
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
Count property
The number of messages that will be generated when running this campaign.
This property will be 0 until a campaign is loaded.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.Load "ALLSUPPORTENGS"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
WScript.Echo "About to generate: " & objCampaignManager.Count & " messages"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.Load("ALLSUPPORTENGS");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
WScript.Echo("About to generate: " + objCampaignManager.Count + " messages");
BatchID property
This is the batch ID for this campaign. The batch ID identifies a specific campaign run.
A batch ID is created by either explicitly starting a batch or by calling Run with a batch description.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.StartBatch "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
WScript.Echo objCampaignManager.BatchID
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.StartBatch("Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
WScript.Echo(objCampaignManager.BatchID);
WScript.Echo("Done!");
CustomSmsMessage property
Use this property to override the SMS message in this campaign.
This text will be used when calling either Run or
CreateNextMessage.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.CustomSmsMessage = "Environmental alert in server room " & _
"112, Rack 15. Check temperature: 35C"
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.CustomSmsMessage = "Environmental alert in server room " +
"112, Rack 15. Check temperature: 35C";
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
CustomPlainTextMessage property
Use this property to override the plain text e-mail body in this campaign.
This text will be used when calling either Run or
CreateNextMessage.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.CustomSubject = "WARNING: Environmental Alert"
objCampaignManager.CustomPlainTextMessage = "Environmental alert in server room " & _
"112, Rack 15. Check temperature: 35C"
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.CustomSubject = "WARNING: Environmental Alert";
objCampaignManager.CustomPlainTextMessage = "Environmental alert in server room " +
"112, Rack 15. Check temperature: 35C";
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
CustomHtmlMessage property
Use this property to override the HTML e-mail body in this campaign.
This text will be used when calling either Run or
CreateNextMessage.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.CustomSubject = "WARNING: Environmental Alert"
objCampaignManager.CustomHtmlMessage = "Environmental alert in server room " & _
"<b>112, Rack 15</b>. Check temperature: <b>35C</b>"
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.CustomSubject = "WARNING: Environmental Alert";
objCampaignManager.CustomHtmlMessage = "Environmental alert in server room " +
"<b>112, Rack 15</b>. Check temperature: <b>35C</b>";
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
CustomSubject property
Use this property to override the e-mail subject in this campaign.
This text will be used when calling either Run or
CreateNextMessage.
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.CustomSubject = "WARNING: Environmental Alert"
objCampaignManager.CustomHtmlMessage = "Environmental alert in server room " & _
"<b>112, Rack 15</b>. Check temperature: <b>35C</b>"
objCampaignManager.Run "ALLSUPPORTENGS", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.CustomSubject = "WARNING: Environmental Alert";
objCampaignManager.CustomHtmlMessage = "Environmental alert in server room " +
"<b>112, Rack 15</b>. Check temperature: <b>35C</b>";
objCampaignManager.Run("ALLSUPPORTENGS", "Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
Run method
Immediately loads and runs the specified campaign. Use this method to run a campaign from a trigger script or from the task scheduler.
This method blocks until all messages in the campaign are created. If you need more fine-grained control, for instance to show progress or cancel sending a batch, consider using the Load method.
Parameters:
- Campaign ID
- (Optional) Batch description
Return value:
Batch ID
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
objCampaignManager.Run "CAMPAIGN1", "Notify all support engineers"
If objCampaignManager.LastError <> 0 Then
WScript.Echo objCampaignManager.LastErrorDescription
WScript.Quit 1
End If
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
objCampaignManager.Run("CAMPAIGN1", "Notify all support engineers");
if (objCampaignManager.LastError !== 0) {
WScript.Echo(objCampaignManager.LastErrorDescription);
WScript.Quit(1);
}
WScript.Echo("Done!");
Load method
Loads a campaign from the datasource into memory.
This method is part of running a campaign with fine-grained control. To just run a single campaign and wait for it to complete, please use the Run method.
Parameters:
- Campaign ID
Return value:
none
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
Set objConstants = CreateObject("AxMmServer.Constants")
objCampaignManager.Load "CAMPAIGN1"
objCampaignManager.StartBatch "Notify all support engineers"
WScript.Echo objCampaignManager.BatchID
objCampaignManager.CreateNextMessage
While objCampaignManager.LastError = 0
objCampaignManager.CreateNextMessage
WEnd
objCampaignManager.StopBatch objConstants.BATCHSTATUS_SUCCESS
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
var objConstants = new ActiveXObject("AxMmServer.Constants");
objCampaignManager.Load("CAMPAIGN1");
objCampaignManager.StartBatch("Notify all support engineers");
WScript.Echo(objCampaignManager.BatchID);
objCampaignManager.CreateNextMessage();
while (objCampaignManager.LastError === 0) {
objCampaignManager.CreateNextMessage();
}
objCampaignManager.StopBatch(objConstants.BATCHSTATUS_SUCCESS);
WScript.Echo("Done!");
StartBatch method
Creates a new batch with the given description. Either explicitly specify which campaign ID this batch refers to or leave it empty to use the campaign ID of the currently loaded campaign.
To finish this batch please use the StopBatch method with one of these constants.
Parameters:
- Batch description
- (Optional) Campaign ID
Return value:
none
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
Set objConstants = CreateObject("AxMmServer.Constants")
objCampaignManager.Load "CAMPAIGN1"
objCampaignManager.StartBatch "Notify all support engineers"
WScript.Echo objCampaignManager.BatchID
objCampaignManager.CreateNextMessage
While objCampaignManager.LastError = 0
objCampaignManager.CreateNextMessage
WEnd
objCampaignManager.StopBatch objConstants.BATCHSTATUS_SUCCESS
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
var objConstants = new ActiveXObject("AxMmServer.Constants");
objCampaignManager.Load("CAMPAIGN1");
objCampaignManager.StartBatch("Notify all support engineers");
WScript.Echo(objCampaignManager.BatchID);
objCampaignManager.CreateNextMessage();
while (objCampaignManager.LastError === 0) {
objCampaignManager.CreateNextMessage();
}
objCampaignManager.StopBatch(objConstants.BATCHSTATUS_SUCCESS);
WScript.Echo("Done!");
StopBatch method
Stops the current batch.
This method stops or closes the current campaign batch with the given status ID.
Use this method when you have previously started a batch using StartBatch.
The status ID needs to be one of these constants.
Parameters:
- Batch status ID
Return value:
none
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
Set objConstants = CreateObject("AxMmServer.Constants")
objCampaignManager.Load "CAMPAIGN1"
objCampaignManager.StartBatch "Notify all support engineers"
WScript.Echo objCampaignManager.BatchID
objCampaignManager.CreateNextMessage
While objCampaignManager.LastError = 0
objCampaignManager.CreateNextMessage
WEnd
objCampaignManager.StopBatch objConstants.BATCHSTATUS_SUCCESS
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
var objConstants = new ActiveXObject("AxMmServer.Constants");
objCampaignManager.Load("CAMPAIGN1");
objCampaignManager.StartBatch("Notify all support engineers");
WScript.Echo(objCampaignManager.BatchID);
objCampaignManager.CreateNextMessage();
while (objCampaignManager.LastError === 0) {
objCampaignManager.CreateNextMessage();
}
objCampaignManager.StopBatch(objConstants.BATCHSTATUS_SUCCESS);
WScript.Echo("Done!");
CreateNextMessage method
Creates the next message from the campaign that was previously loaded with Load.
To create all messages from the currently loaded campaign, call this method until LastError is no longer zero.
Parameters:
- None
Return value:
none
Example:
Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
Set objConstants = CreateObject("AxMmServer.Constants")
objCampaignManager.Load "CAMPAIGN1"
objCampaignManager.StartBatch "Notify all support engineers"
WScript.Echo objCampaignManager.BatchID
objCampaignManager.CreateNextMessage
While objCampaignManager.LastError = 0
objCampaignManager.CreateNextMessage
WEnd
objCampaignManager.StopBatch objConstants.BATCHSTATUS_SUCCESS
WScript.Echo "Done!"
var objCampaignManager = new ActiveXObject("AxMmServer.CampaignManager");
var objConstants = new ActiveXObject("AxMmServer.Constants");
objCampaignManager.Load("CAMPAIGN1");
objCampaignManager.StartBatch("Notify all support engineers");
WScript.Echo(objCampaignManager.BatchID);
objCampaignManager.CreateNextMessage();
while (objCampaignManager.LastError === 0) {
objCampaignManager.CreateNextMessage();
}
objCampaignManager.StopBatch(objConstants.BATCHSTATUS_SUCCESS);
WScript.Echo("Done!");