SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
DKIM / DomainKey
FTP
HTML-to-XML
HTTP
MHT
MIME
NTLM
RSA
Diffie-Hellman
DSA
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
String
Tar
Upload
XML
XMP
Zip

Bz2
CSV
FileAccess
Byte Array
RSS
Atom
Self-Extractor

Send SMS Message

Demonstrates how to send an SMS text message to a mobile phone. An SMS text message may be sent via email using the free Email To SMS Gateways provided by the carriers. The gateway domains for major US carriers are shown immediately below. (A more complete list of US and International SMS gateways is provided after the source code listing below.)

Boost Mobile: PhoneNumber@myboostmobile.com
T-Mobile: PhoneNumber@tmomail.net
Virgin Mobile: PhoneNumber@vmobl.com
Cingular: PhoneNumber@cingularme.com
Sprint Nextel: PhoneNumber@messaging.sprintpcs.com
Verizon: PhoneNumber@vtext.com
Nextel: PhoneNumber@messaging.nextel.com
US Cellular: PhoneNumber@email.uscc.net
SunCom: PhoneNumber@tms.suncom.com
Powertel: PhoneNumber@ptel.net
AT&T (Cingular): PhoneNumber@txt.att.net
Alltel: PhoneNumber@message.alltel.com
Metro PCS: PhoneNumber@MyMetroPcs.com


where PhoneNumber = your 10 digit phone number

Maximum SMS Length:
Each SMS message can be up to 160 total characters in length. If non-Latin alphabets like Chinese or Arabic are used, the limit is 70 characters.

Long Messages:
Most mobile phones support "long messages". This feature splits up messages longer than 160 characters into multiple messages. If the body text of your SMS email is longer than 160 characters, it may be delivered as multiple text messages on phones that do not support long messages, or it may be automatically split and re-assembled into a single message on phones that do support long messages. The splitting of a long message would happen at the SMS gateway, and not within the Chilkat component/library.

Important: Some SMTP servers do not actually send an email until the connection is closed. In these cases, it is necessary to call CloseSmtpConnection for the mail to be sent. Most SMTP servers send the email immediately, and it is not required to close the connection.

More information about minimizing SMTP connections.

Download Chilkat Email ActiveX

Download Chilkat IMAP ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    --  The mailman object is used for sending and receiving email.
    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan2', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Any string argument automatically begins the 30-day trial.
    DECLARE @success int

    EXEC sp_OAMethod @mailman, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT

        PRINT @sTmp0
        RETURN
      END

    --  Set the SMTP server.
    EXEC sp_OASetProperty @mailman, 'SmtpHost', 'smtp.chilkatsoft.com'

    --  Set the SMTP login/password (if required)
    EXEC sp_OASetProperty @mailman, 'SmtpUsername', 'myUsername'
    EXEC sp_OASetProperty @mailman, 'SmtpPassword', 'myPassword'

    --  Create a new email object
    DECLARE @email int
    EXEC @hr = sp_OACreate 'Chilkat.Email2', @email OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @email, 'Subject', 'Test SMS text message'
    EXEC sp_OASetProperty @email, 'Body', 'This is a test SMS text message'
    EXEC sp_OASetProperty @email, 'From', 'Chilkat Support <support@chilkatsoft.com>'
    --  Use the 10-digit phone number and SMS gateway domain here:
    EXEC sp_OAMethod @email, 'AddTo', NULL, 'John Doe', '1234567890@txt.att.net'

    --  Call SendEmail to connect to the SMTP server and send.
    --  The connection (i.e. session) to the SMTP server remains
    --  open so that subsequent SendEmail calls may use the
    --  same connection.
    EXEC sp_OAMethod @mailman, 'SendEmail', @success OUT, @email
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        RETURN
      END

    --  Some SMTP servers do not actually send the email until
    --  the connection is closed.  In these cases, it is necessary to
    --  call CloseSmtpConnection for the mail to be  sent.
    --  Most SMTP servers send the email immediately, and it is
    --  not required to close the connection.  We'll close it here
    --  for the example:
    EXEC sp_OAMethod @mailman, 'CloseSmtpConnection', @success OUT
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
      END

    PRINT 'Mail Sent!'

    --  ----------------------------------------------------------------
    --  
A more complete list of SMS gateways:


--------------------  Austria --------------------
MaxMobil 	xPhoneNumber@max.mail.at
One Connect 	PhoneNumber@onemail.at
T-Mobile 	PhoneNumber@sms.t-mobile.at

--------------------  Australia --------------------
Blue Sky Frog 	PhoneNumber@blueskyfrog.com
Optus Mobile 	PhoneNumber@optusmobile.com.au

--------------------  Belgium --------------------
Mobistar 	PhoneNumber@mobistar.be

--------------------  Bermuda --------------------
Mobility 	PhoneNumber@ml.bm

--------------------  Brazil --------------------
Nextel 	PhoneNumber@nextel.com.br

--------------------  Canada --------------------
Bell Mobility 	PhoneNumber@txt.bell.ca
Bell Mobility 	PhoneNumber@txt.bellmobility.ca
Fido 	PhoneNumber@fido.ca
Microcell 	PhoneNumber@fido.ca
Manitoba Telecom Systems 	PhoneNumber@text.mtsmobility.com
NBTel 	PhoneNumber@wirefree.informe.ca
PageMart 	PhoneNumber@pmcl.net
PageNet 	PhoneNumber@pagegate.pagenet.ca
Rogers 	PhoneNumber@pcs.rogers.com
Telus 	PhoneNumber@msg.telus.com

--------------------  Chile --------------------
Bell South 	PhoneNumber@bellsouth.cl

--------------------  Czech Republic --------------------
Eurotel 	+ccaaxxxxxxx@sms.eurotel.cz
Oskar 	PhoneNumber@mujoskar.cz

--------------------  Denmark --------------------
Sonofon 	xxxxxxxx@note.sonofon.dk
Tele Danmark Mobil 	xxxxxxxx@sms.tdk.dk
Telia Denmark 	PhoneNumber@gsm1800.telia.dk

--------------------  Estonia --------------------
EMT 	PhoneNumber@sms.emt.ee

--------------------  France --------------------
SFR 	PhoneNumber@sfr.fr

--------------------  Germany --------------------
T-Mobile 	+49xxxxxxx@t-d1-sms.de
Mannesmann Mobilefunk 	xxxxxxx@d2-message.de
E-Plus 	0177xxxxxxx.sms@eplus.de

--------------------  Hungary --------------------
PGSM 	3620xxxxxxx@sms.pgsm.hu

--------------------  India --------------------
BPL mobile 	PhoneNumber@bplmobile.com
Chennai RPG Cellular 	PhoneNumber@rpgmail.net
Chennai Skycell / Airtel 	PhoneNumber@airtelchennai.com
Delhi Aritel 	PhoneNumber@airtelmail.com
Delhi Hutch 	PhoneNumber@delhi.hutch.co.in
Idea Cellular 	PhoneNumber@ideacellular.net
Orange 	PhoneNumber@orangemail.co.in

--------------------  Ireland --------------------
Meteor 	PhoneNumber@sms.mymeteor.ie

--------------------  Italy --------------------
Telecom Italia Mobile 	33xxxxxxxx@posta.tim.it
Vodafone Omnitel 	34xxxxxxxx@vizzavi.it
Vodafone 	PhoneNumber@sms.vodafone.it

--------------------  Japan --------------------
Vodafone Japan 	PhoneNumber@c.vodafone.ne.jp
Vodafone Japan 	PhoneNumber@h.vodafone.ne.jp
Vodafone Japan 	PhoneNumber@t.vodafone.ne.jp

--------------------  Latvia --------------------
Kyivstar 	PhoneNumber@smsmail.lmt.lv
LMT 	9xxxxxx@smsmail.lmt.lv
Tele2 	PhoneNumber@sms.tele2.lv

--------------------  Lebanon --------------------
Cellis / LibanCell 	9613xxxxxx@ens.jinny.com.lb

--------------------  Luxembourg --------------------
P&T Luxembourg 	PhoneNumber@sms.luxgsm.lu

--------------------  Malaysia --------------------
Celcom 	019xxxxxxx@sms.celcom.com.my  	 
--------------------  The Netherlands
Dutchtone / Orange-NL 	PhoneNumber@sms.orange.nl

--------------------  Norway --------------------
Netcom 	PhoneNumber@sms.netcom.no
Telenor 	PhoneNumber@mobilpost.no

--------------------  Panama --------------------
Cable and Wireless 	PhoneNumber@cwmovil.com
--------------------  Poland
Plus GSM 	+4860xxxxxxx@text.plusgsm.pl

--------------------  Portugal --------------------
Telcel 	91xxxxxxx@sms.telecel.pt
Optimus 	93xxxxxxx@sms.optimus.pt
TMN 	96xxxxxxx@mail.tmn.pt

--------------------  Russia --------------------
BeeLine GSM 	PhoneNumber@sms.beemail.ru
MTS 	7xPhoneNumber@sms.mts.ru
Personal Communication 	sms@pcom.ru (number in subject line)
Primtel 	PhoneNumber@sms.primtel.ru
SCS-900 	PhoneNumber@scs-900.ru
Uraltel 	PhoneNumber@sms.uraltel.ru
Vessotel 	PhoneNumber@pager.irkutsk.ru

--------------------  Serbia and Montenegro --------------------
Mobtel Srbija 	PhoneNumber@mobtel.co.yu

--------------------  Singapore --------------------
MiWorld 	PhoneNumber@m1.com.sg
Mobileone 	PhoneNumber@m1.com.sg

--------------------  Slovenia --------------------
Mobitel 	xxxxxx@linux.mobitel.si
Si Mobil 	xxxxxx@simobil.net

--------------------  Spain --------------------
Movistar 	PhoneNumber@correo.movistar.net
Vodafone 	PhoneNumber@vodafone.es

--------------------  Sweden --------------------
Comviq GSM 	467xxxxxxxx@sms.comviq.se
Europolitan 	4670xxxxxxx@europolitan.se 	 

--------------------  Switzerland --------------------
Sunrise Mobile 	PhoneNumber@freesurf.ch
Sunrise Mobile 	PhoneNumber@mysunrise.ch
Swisscom 	PhoneNumber@bluewin.ch

--------------------  Tanzania --------------------
Mobitel 	PhoneNumber@sms.co.tz

--------------------  Ukraine --------------------
Golden Telecom 	PhoneNumber@sms.goldentele.com
Kyivstar 	xPhoneNumber@2sms.kyivstar.net
UMC 	PhoneNumber@sms.umc.com.ua

--------------------  United Kingdom --------------------
Orange 	0973xxxxxx@omail.net
Orange 	PhoneNumber@orange.net
O2 	name@o2.co.uk
O2 (M-mail) 	PhoneNumber@mmail.co.uk
T-Mobile UK 	PhoneNumber@t-mobile.uk.net
Vodafone UK 	PhoneNumber@vodafone.net

--------------------  United States --------------------
3 River Wireless 	PhoneNumber@sms.3rivers.net
Advantage Communications 	PhoneNumber@advantagepaging.com
AirVoice 	PhoneNumber@mmode.com
Airtouch Pagers 	PhoneNumber@airtouch.net
Airtouch Pagers 	PhoneNumber@airtouchpaging.com
Airtouch Pagers 	PhoneNumber@alphapage.airtouch.com
Airtouch Pagers 	PhoneNumber@myairmail.com
AllTel 	PhoneNumber@message.alltel.com
Alltel PCS 	PhoneNumber@message.alltel.com
Alltel 	PhoneNumber@alltelmessage.com
Ameritech Paging 	PhoneNumber@pageapi.com
Arch Pagers (PageNet) 	PhoneNumber@archwireless.net
Arch Pagers (PageNet) 	PhoneNumber@epage.arch.com
Bell South (Blackberry) 	PhoneNumber@bellsouthtips.com
Bell South Mobility 	PhoneNumber@blsdcs.net
Bell South 	PhoneNumber@blsdcs.net
Bell South 	PhoneNumber@sms.bellsouth.com
Bell South 	PhoneNumber@wireless.bellsouth.com
Bluegrass Cellular 	PhoneNumber@sms.bluecell.com
Boost Mobile 	PhoneNumber@myboostmobile.com
Boost 	PhoneNumber@myboostmobile.com
CallPlus 	PhoneNumber@mmode.com
Carolina Mobile Communications 	PhoneNumber@cmcpaging.com
Cellular One East Coast 	PhoneNumber@phone.cellone.net
Cellular One PCS 	PhoneNumber@paging.cellone-sf.com
Cellular One South West 	PhoneNumber@swmsg.com
Cellular One West 	PhoneNumber@mycellone.com
Cellular One 	PhoneNumber@message.cellone-sf.com
Cellular One 	PhoneNumber@mobile.celloneusa.com
Cellular One 	PhoneNumber@sbcemail.com
Cellular South 	PhoneNumber@csouth1.com
Central Vermont Communications 	PhoneNumber@cvcpaging.com
CenturyTel 	PhoneNumber@messaging.centurytel.net
Cingular (GSM) 	PhoneNumber@cingularme.com
Cingular (TDMA) 	PhoneNumber@mmode.com
Cingular Wireless 	PhoneNumber@mobile.mycingular.net
Cingular 	PhoneNumber@cingularme.com
Communication Specialists 	xxxxxxx@pageme.comspeco.net
Cook Paging 	PhoneNumber@cookmail.com
Corr Wireless Communications 	PhoneNumber@corrwireless.net
Dobson Communications Corporation 	PhoneNumber@mobile.dobson.net
Dobson-Alex Wireless / Dobson-Cellular One 	PhoneNumber@mobile.cellularone.com
Edge Wireless 	PhoneNumber@sms.edgewireless.com
GCS Paging 	PhoneNumber@webpager.us
GTE 	PhoneNumber@gte.pagegate.net
GTE 	PhoneNumber@messagealert.com
Galaxy Corporation 	PhoneNumber@sendabeep.net
GrayLink / Porta-Phone 	PhoneNumber@epage.porta-phone.com
Houston Cellular 	PhoneNumber@text.houstoncellular.net
Inland Cellular Telephone 	PhoneNumber@inlandlink.com
JSM Tele-Page 	PhoneNumber@jsmtel.com
Lauttamus Communication 	PhoneNumber@e-page.net
MCI Phone 	PhoneNumber@mci.com
MCI 	PhoneNumber@pagemci.com
Metro PCS 	PhoneNumber@metropcs.sms.us
Metro PCS 	PhoneNumber@mymetropcs.com
MetroPCS 	PhoneNumber@mymetropcs.com
Metrocall 2-way 	PhoneNumber@my2way.com
Metrocall 	PhoneNumber@page.metrocall.com
Midwest Wireless 	PhoneNumber@clearlydigital.com
Mobilecom PA 	PhoneNumber@page.mobilcom.net
Mobilfone 	PhoneNumber@page.mobilfone.com
Morris Wireless 	PhoneNumber@beepone.net
NPI Wireless 	PhoneNumber@npiwireless.com
Nextel 	PhoneNumber@messaging.nextel.com
Nextel 	PhoneNumber@page.nextel.com
Ntelos 	PhoneNumber@pcs.ntelos.com
Omnipoint 	PhoneNumber@omnipoint.com
Omnipoint 	PhoneNumber@omnipointpcs.com
OnlineBeep 	PhoneNumber@onlinebeep.net
PCS One 	PhoneNumber@pcsone.net
Pacific Bell 	PhoneNumber@pacbellpcs.net
PageMart 	PhoneNumber@pagemart.net
PageOne NorthWest 	PhoneNumber@page1nw.com
Pioneer / Enid Cellular 	PhoneNumber@msg.pioneerenidcellular.com
Price Communications 	PhoneNumber@mobilecell1se.com
ProPage 	PhoneNumber@page.propage.net
Public Service Cellular 	PhoneNumber@sms.pscel.com
Qualcomm 	name@pager.qualcomm.com
Qwest 	PhoneNumber@qwestmp.com
RAM Page 	PhoneNumber@ram-page.com
ST Paging 	pin@page.stpaging.com
Safaricom 	PhoneNumber@safaricomsms.com
Satelindo GSM 	PhoneNumber@satelindogsm.com
Satellink 	xxxxxxxxx.pageme@satellink.net
Simple Freedom 	PhoneNumber@text.simplefreedom.net
Skytel Pagers 	PhoneNumber@email.skytel.com
Skytel Pagers 	PhoneNumber@skytel.com
Smart Telecom 	PhoneNumber@mysmart.mymobile.ph
Southern LINC 	PhoneNumber@page.southernlinc.com
Southwestern Bell 	PhoneNumber@email.swbw.com
Sprint PCS 	PhoneNumber@messaging.sprintpcs.com
Sprint 	PhoneNumber@sprintpaging.com
SunCom 	PhoneNumber@tms.suncom.com
Surewest Communications 	PhoneNumber@mobile.surewest.com
T-Mobile 	PhoneNumber@tmomail.net
TIM 	PhoneNumber@timnet.com
TSR Wireless 	PhoneNumber@alphame.com
TSR Wireless 	PhoneNumber@beep.com
Teletouch 	PhoneNumber@pageme.teletouch.com
Telus 	PhoneNumber@msg.telus.com
The Indiana Paging Co 	xxxx@pager.tdspager.com
Triton 	PhoneNumber@tms.suncom.com
US Cellular 	PhoneNumber@email.uscc.net
USA Mobility 	PhoneNumber@mobilecomm.net
Unicel 	PhoneNumber@utext.com
Verizon PCS 	PhoneNumber@myvzw.com
Verizon Pagers 	PhoneNumber@myairmail.com
Verizon 	PhoneNumber@vtext.com
Virgin Mobile 	PhoneNumber@vmobl.com
Virgin Mobile 	PhoneNumber@vxtras.com
WebLink Wireless 	PhoneNumber@pagemart.net
West Central Wireless 	PhoneNumber@sms.wcc.net
Western Wireless 	PhoneNumber@cellularonewest.com
Wyndtell 	PhoneNumber@wyndtell.com

END
GO

 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.