How can we help?

Forward E-mail to multiple SMS recipients


You can  use the SMS Server to forward an e-mail message to multiple SMS recipients.

In this example we’ll forward an e-mail alert to all members of a dedicated ICT support team. An excel sheet contains the contact information of the support team.

This example will walk through the configuration of the following items:

  • Create an SMS campaign for the ICT support team
  • Setup an e-mail forward trigger from a template
  • Modify the trigger to use an existing SMS Campaign

Before starting please make sure that you have already configured these channels:

  • An incoming e-mail channel. This can be either IMAP or POP3.
  • An outgoing SMS channel. This can be either GSM, HTTP or SMPP.

Create the ICT Support campaign

The ICT support campaign contains a reference to the data-source containing the ICT support contact details. In this example it is going to be a central Microsoft Excel sheet. But, as you will see, it could have been an external database or CSV file as well.

Start creating a new campaign by following these steps:

  1. Open the SMS Server manager application
  2. Click open the ‘Campaigns‘ section in the tree view on the left
  3. Click on ‘New Campaign
SMS Server Manager - Campaign Overview

SMS Server Manager – Campaign Overview

We’ll call the campaign: ‘CONSIGNMENT’. With the description: ‘Consignment team members‘.

This example uses an existing SMPP channel to send the SMS messages and uses Excel as the data source.

Campaign Wizard - Excel

Campaign Wizard – Excel

The campaign wizard will ask you to format an SMS text for the campaign. This text can be anything as we won’t actually use it when forwarding the E-mail message.

When forwarding the e-mail messages to the campaign we’ll use the actual text of the e-mail so this can just be a test message to test the campaign itself.

Campaign Wizard - Test Message

Campaign Wizard – Test Message

After the campaign is created you can test if it works by just clicking the green ‘play‘ button in the campaign overview.

Setup the e-mail forward trigger

We’ll setup an e-mail forward trigger from the ‘Forward Trigger Template‘.

Even though it’s not exactly what we want, since it only forwards to a single recipient, it’s a good starting point. We’ll edit the trigger to match our requirements after we’ve created it.

Start creating a new trigger in the SMS Server manager by following these steps:

  1. Click open the ‘Triggers‘ section in the tree view on the left
  2. Click on the ‘New Trigger‘ link in the view on the right
  3. Select ‘Forward Trigger Template‘ from the list of available trigger templates
  4. Click on ‘Create
Trigger Template - Forward Trigger

Trigger Template – Forward Trigger

We’ll call the trigger: ‘FWDTOTEAM’. With the description: ‘Forward e-mail alerts to team‘.

For this example we’re choosing VBScript as the scripting language for this trigger. If you’re more comfortable with JavaScript you can choose JavaScript.

In the next page choose to forward from your incoming e-mail channel to the SMPP channel (E-Mail to SMS). This will make sure that the trigger condition is generated exactly as we need it.

Forward Trigger Template - Channels

Forward Trigger Template – Channels

The final page will ask you to format the forward text by matching e-mail parts to SMS parts. You can leave this to the defaults.

Modify the trigger

Next we’ll have a look at the trigger that was generated by the forward template and we’ll change it to forward to a campaign instead.

You can find trigger script by:

  1. Click open the ‘Triggers‘ section in the tree view on the left
  2. Click on the ‘Edit (pencil) icon on the right‘ side of the trigger that was just created
  3. Select the ‘VBScript tab‘ on the top of the ‘Edit Trigger’ dialog.
  4. Click on the ‘Edit (pencil)’ icon next to the script path.
Forward Trigger - Condition

Forward Trigger – Condition

The script contains two parts. First is the actual trigger function which looks like this:

' // ========================================================================
' // Function: ProcessMessageEx
' // ------------------------------------------------------------------------
' // ProcessMessageEx trigger function to process incoming messages
' // ========================================================================
Function ProcessMessageEx(objMessageIn, objMessageDB, dctContext)

	Log ">> ProcessMessageEx"
	
	Forward objMessageIn, objMessageDB 
	
	Log "<< ProcessMessageEx"

End Function

That part we can leave as it is. However, the ‘Forward‘ function needs to change.  You can change the forward function, which starts at the text: ‘Function Forward(objMessageIn, objMessageDB)‘ and ends at ‘End Function‘  with the following text:

' // ========================================================================
' // Forward
' // ------------------------------------------------------------------------
' // Automatically forward this message
' // ========================================================================
Function Forward(objMessageIn, objMessageDB)

  Log ">> Forward"

  ' prefer the plain text body
  sBody = objMessageIn.BodyPlainText
  If sBody = "" Then
    sBody = objMessageIn.BodyHtml
  End If

  ' make sure there is no HTML formatting in the body
  Set objHtmlToText = CreateObject("AxEmail.Message")
  sBody = objHtmlToText.HtmlToPlainText(sBody)

  ' run the consignment campaign with a custom SMS body
  Set objCampaignManager = CreateObject("AxMmServer.CampaignManager")
  objCampaignManager.CustomSmsMessage = sBody
  objCampaignManager.Run "CONSIGNMENT"

  ' if there was a problem running the campaign update the e-mail status
  If objCampaignManager.LastError <> 0 Then
    objMessageIn.StatusID = g_objConstants.MESSAGESTATUS_FAILED
    objMessageIn.AddTrace objCampaignManager.LastErrorDescription
  Else
    objMessageIn.AddTrace "Forwarded to 'CONSIGNMENT' campaign'"
  End If

  Log "<< Forward"

End Function

The new function body first creates the CampaignManager object and sets a custom SMS message format that will override the only already specified in the campaign. Next it runs the CONSIGNMENT campaign to send the customized message to everyone in the CONSIGNEMENT campaign data-source.

It also uses the ‘HtmlToPlainText‘ method to strip any HTML tags that may be part of the e-mail message so the SMS does not grow too large.

Finally. Don’t forget to enable the trigger so that it’s automatically applied to any incoming e-mail.

SMS Server Manager - Enabled Trigger

SMS Server Manager – Enabled Trigger