You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use MMS Toolkit > SMTP (MM4) > VBScript
Quicklinks
The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality. SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem. MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).
SMS features:
MMS features:
Pager features:
This document describes how the SMS and MMS Toolkit can be integrated into VBScript projects.
Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Create a new script using your favorite editor. You can simply use notepad. However, a VBScript editor is recommended, so you can browse through objects, objects properties and object functions.
You're now able to write a more advanced VBScript script to send MMS using MMS Toolkit.
Create a new VBScript file called DEMO.VBS. It is recommended to insert the following line on top of your code:
Option Explicit
This statement requires that all variable names be defined (with the Dim statement), to avoid simple typos that can cause incredible headaches and long debugging sessions for something that should have never happened.
Now, declare the SMS and MMS Toolkit objects:
Dim objMm4Protocol Dim objMmsMessage Dim objMmsConstants Dim objMmsSlide
Create the MMS objects like this:
Set objMm4Protocol = CreateObject( "ActiveXperts.MmsProtocolMm4" ) Set objMmsMessage = CreateObject( "ActiveXperts.MmsMessage" ) Set objMmsConstants = CreateObject( "ActiveXperts.MmsConstants" ) Set objMmsSlide = CreateObject( "ActiveXperts.MmsSlide" )
Now, add the following lines to the file to have your fist MMS Toolkit VBScript program:
WScript.Echo "Version: " & objMm4Protocol.Version WScript.Echo "Expiration Date: " & objMm4Protocol.ExpirationDate
You can now send MMS messages.
The following VBScript code shows how to send a MMS message using SMTP:
Option Explicit Dim objMmsConstants, objMmsMessage, objMm4Protocol, objMmsSlide Set objMm4Protocol = CreateObject ( "ActiveXperts.MmsProtocolMm4" ) Set objMmsMessage = CreateObject ( "ActiveXperts.MmsMessage" ) Set objMmsSlide = CreateObject ( "ActiveXperts.MmsSlide" ) Set objMmsConstants = CreateObject ( "ActiveXperts.MmsConstants" ) ' MMSlide: Add duration, attachments(s) and text(s) objMmsSlide.Clear objMmsSlide.Duration = 10 'Display this screen for 10 seconds objMmsSlide.AddAttachment "logo.gif" objMmsSlide.AddText "The ActiveXperts logo" ' MmsMessage: Set properties objMmsMessage.Clear objMmsMessage.Subject = "MMS Message" objMmsMessage.AddRecipient AskRecipient() ' MmsMessage: Set advanced properties objMmsMessage.Class = objMmsConstants.asMMS_CLASS_PERSONAL objMmsMessage.Priority = objMmsConstants.asMMS_PRIORITY_HIGH ' MmsMessage: Add the slide created above. Note:You can add multiple slides objMmsMessage.AddSlide ( objMmsSlide ) ' MmsProtocolMm4: Set Provider objMm4Protocol.ProviderHost = "192.168.31.93" objMm4Protocol.ProviderPort = 25 objMm4Protocol.ProviderAccount = "mm4" objMm4Protocol.ProviderPassword = "secret" 'objMm4Protocol.ProviderDomain = "activexperts.dom" 'objMm4Protocol.ProviderMM4Version = objMmsConstants.asMMS_VERSION_5_2_0; ' MmsProtocolMm4: Set log file objMm4Protocol.LogFile = "mm4log.txt" ' MmsProtocolMm4: send now objMm4Protocol.Send ( objMmsMessage ) WScript.Echo "Send, result: " & objMm4Protocol.LastError & " (" & _ objMm4Protocol.GetErrorDescription ( objMm4Protocol.LastError ) & ")" & vbCrLf 'WScript.Echo "Provider response: " & objMm4Protocol.ProviderResponse & vbCrLf 'WScript.Echo "MessageID: " & objMm4Protocol.MessageId ' MmsProtocolMm4: ready WScript.Echo "Ready." ' *************************************************************************** ' Function AskRecipient ' *************************************************************************** Function AskRecipient Dim strRecipient Do strRecipient = inputbox( "Enter a recipient ( mobile number or e-mail address )", "Input" ) Loop until strRecipient <> "" AskRecipient = strRecipient End Function
There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.