How can we help?

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 message 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 datasource into memory
StartBatch Start a batch to run a campaign with
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

LastErrorDescription property

Describes the result of the last methods 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

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

Count property

The number of message 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"

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!"

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

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

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

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

Run method

Immediately loads and runs the specified campaign. Use this to run a campaign from a trigger script or from the task scheduler.

This method will block until all of the message in the campaign are created. If you need more fine-grained control to, for instance, be able to show progress or cancel sending a batch consider using the method described in ‘Load

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!"

Load method

Loads a campaign from the datasource and into memory.

This method is a part of running campaign with fine-grained control. To just run a single campaign and wait for it to complete please look at 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!"

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!"

StopBatch method

Stop the current batch.

This method stops / 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!"

CreateNextMessage method

Creates the next message from campaign that was previously loaded with ‘Load‘.

To create all messages from the currently loaded campaign call this method until ‘LastError’ is set.

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!"