您的位置:首页 > 其它

Sending SMS from Dynamics NAV with 5 lines of code

2011-06-23 08:50 363 查看

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:

Outlook 2010

Exchange 2010

NAV (any version supporting automations…)

Mobile phone with Windows Mobile 6.1 (with some update) or 6.5

Step 1

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…

Step 2

Create code in NAV, which will send the SMS. It is easy:

SendSMS(ToNumbers : Text[30];Body : Text[1000])

begin
if ISCLEAR(OutlookApp) then
CREATE(OutlookApp);

MobileItem := OutlookApp.CreateItem(11); //11 – SMS, 12 – MMS
MobileItem."To" := ToNumbers; //e.g. +420666777555
MobileItem.Body := Body;
MobileItem.Send(False);
end;

Where:

OutlookApp Automation 'Microsoft Outlook 14.0 Object Library'.Application
MobileItem Automation 'Microsoft Outlook 14.0 Object Library'.MobileItem

Step 3

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…

Conclusion

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. :-)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐