Sending SMS from Dynamics NAV with 5 lines of code
After long time, I have found few minutes (ok, hour and something…) to test one idea I had. It is not long ago, when we switched our Exchange from older version to version 2010. Because I am using Windows Mobile 6.5 on my phone, I have noticed the new possibility to synchronize SMS from/to mobile with exchange/outlook. Bingo! If I am able to create the item in outlook from within NAV (and yes, I am able, I can create emails etc.), I can send SMS from NAV in this way. Easy!
What you need:
NAV (any version supporting automations…)
Mobile phone with Windows Mobile 6.1 (with some update) or 6.5
Setup the mobile to synchronize all with the exchange, mainly the SMS. Just follow standard procedure, this blog is not about setting up the mobile phone…
Create code in NAV, which will send the SMS. It is easy:
SendSMS(ToNumbers : Text;Body : Text)
if ISCLEAR(OutlookApp) then
MobileItem := OutlookApp.CreateItem(11); //11 – SMS, 12 – MMS
MobileItem."To" := ToNumbers; //e.g. +420666777555
MobileItem.Body := Body;
OutlookApp Automation 'Microsoft Outlook 14.0 Object Library'.Application
MobileItem Automation 'Microsoft Outlook 14.0 Object Library'.MobileItem
Call the function where you need. You need to just run it under profile, which have outlook set to syncing SMS with phone. It will create the sms, and after the sms is synced into the mobile phone, the mobile phone will send the SMS for your wherever you want. If you want to have central sending machine, use the NAS or WebServices to send SMS based on some queue…
As you can see, you do not need to pay for some 3rd party service. You only need some mobile phone with good tarif. Of course, this is not good solution for some bulk sending, but for some standard notifications it is suitable.
Do not forget to make some maintenance of the outlook account, like deleting old sent items etc. You can do it through some code in NAV or may be somehow on the exchange.
And yes, you can read the incoming sms in similar way, just read the items from the outlook.
Some examples of usage:
Sending SMS to admin when session limit is reached (using NAS).
Sending SMS to customer when order is prepared to ship.
Generally: sending SMS when <some action> in NAV happen. :-)