How to Use MOBITEK SMS API version 7 in Visual Basic .Net


REVISION HISTORY

EDITION ISSUED DATE REMARK
3rd 18th of July, 2013 Revised FAQ section
2nd 1st of August, 2012 FAQ section added
1st 1st of August, 2009 Draft release

 

COPYRIGHT

© 2012 MOBITEK System Sdn. Bhd. All rights reserved.

No part of this document may be reproduced, distributed, stored in a retrieval system or translated into any language, in any form or by any means, electronic, mechanical, magnetic, optical, photocopying, manual or otherwise, without the prior written permission of MOBITEK System Sdn. Bhd.

 

TRADEMARK

MOBITEK®  is a registered trademark owns by MOBITEK System Sdn. Bhd.
Product names, logos, brands and other trademarks referred in this document are the property of their respective trademark holders and are used only to directly describe the products being provided.

 

DISCLAIMER

MOBITEK makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose.
Furthermore, MOBITEK reserves the right to revise this publication and to make changes from time to time in the contents hereof without obligation to notify any person of such revision or changes.
Trademarks and Registered Trademarks Products and product names mentioned in this document may be trademarks or registered trademarks of their respective owners.

 

ACKNOWLEDGEMENT

We like to extend our appreciation to the following trainees who had contributed to the authoring of this manual:-

  1. Mr. Alfred Ang Yit Lun, UNIVERSITY PUTRA MALAYSIA
  2. Mr. Chai Yick Loong, UNIVERSITY PUTRA MALAYSIA
  3. Ms. Yela, MASA College

 

SPECIFICATION

API TYPE: ActiveX DLL (Component Object Model) for Windows only

ActiveX File Name: MobitekSMSAPI7.dll

Requirement:

  1. You must be a software developer and you must posses programming skill and knowledge on using ActiveX component.
  2. Visual Basic 2008 Express, Visual Studio 2008

 

SCOPE OF THIS MANUAL

This manual provides a brief guide on using SMS API in Visual Basic 2008.
This manual:-

  1. does not teach you how to write Visual Basic;
  2. does not teach yo how to code; and
  3. does not teach you how to integrate with database or external system.

For further information about the SMS API (methods and properties), please refer to the help file, “SMS API v5 Manual.chm” that is located in the CD.
To obtain a sample code written in Visual Basic 2008, please refer to the CD.

 

BENEFITS

The benefits for software developer in using MOBITEK®  SMS API version 7 are:

  1. rapid development of a SMS Gateway
  2. full control of the message flow, business logic and the design of SMS Gateway
  3. can decide how to handle incoming message – trigger an event, or launch an external application
  4. can decide where to store the incoming message – in database, in text, or in XML
  5. can decide who should receive outgoing message, when to send, what the send
  6. integrate SMS feature with external software application
  7. able to check credit balance of prepaid account
  8. able to reload, top-up the prepaid account

 

SET-UP

Step 1: Ensure GSM modem is properly configured with the correct COM port (refer to the GSM modem installation guide).

Step 2: Install the SMS API (COM-ActiveX), i.e. Run the “setup.exe” from the CD.

Step 3: Open Visual Basic 2008, go to “New Project”, insert the project name and click “OK”.

SMS API 7 in VB.net-01

Step 4: To configure to use the “MobitekSMSAPI7.dll”, go to “Project > Add Reference”.

SMS API 7 in VB.net-02

Step 5: Select “COM” and find “MobitekSMSAPI7”. Click “OK” after that.

SMS API 7 in VB.net-03

Step 6: To confirm the “MobitekSMSAPI7.dll” file is referenced properly, go to “View > Object Browser”.

SMS API 7 in VB.net-04

Step 7: If you see “Interop.MobitekSMSAPI7” in the list, mean the “MobitekSMSAPI7.dll” file was add in successfully.

SMS API 7 in VB.net-05

Step 8: To start write a source code, go to “Project > Add Module > Name”.

SMS API 7 in VB.net-06

Step 9: At the beginning, user have to create object for SMS in file Module1.vb.

Public SMS As New MobitekSMSAPI7.SMS”

SMS API 7 in VB.net-07

Step 10: To insert the source code, type “SMS.” like below.

When you type it, you will see another box is appear, and you may select from it.

SMS API 7 in VB.net-08

This also mean that, the “MobitekSMSAPI7.dll” file is referenced successfully and the object for SMS is created.

Step 11: You can continue writing your code. And happy coding!

 

FAQ

Question: When calling the method Modem.Init(), this error appears – “Retrieving the COM class factory for component with CLSID {C7B56BA9-90BC-4B2B-BA02-DF1FCBE506A7} failed due to the following error: 80040154.

Answer: In Visual Studio .Net, modify your project’s platform from “Any CPU” to “x86” in “Project Properties > Build/Platform’s Target. Refer figures below for step-by-step guide.

 

Step-By-Step Guide
Figure 1: Tools > Option SMS API 7 in VB.net-09
Figure 2: Show advanced build configurations > OK SMS API 7 in VB.net-10
Figure 3: Build > Configuration Manager SMS API 7 in VB.net-11
Figure 4: Active solution platform > New SMS API 7 in VB.net-12
Figure 5: Select new platform > x86 SMS API 7 in VB.net-13
Figure 6: Change Any CPU to x86 SMS API 7 in VB.net-14
Figure 7: Platform changed to x86 SMS API 7 in VB.net-15

 

Question: How to solve the error message — “Type Initialization was unhandled”?

Root Cause Solution
The COM "MobitekSMSAPI7.dll" is not referenced at all; To re-reference COM
The COM "MobitekSMSAPI7.dll" is referenced but was not properly registered during installation; Re-register the COM.
In 64 bit Windows OS; the Visual Studio (or VB.net Express) is configured to be build on "Any CPU" platform Please refer to the screen capture of FAQ No 1 to configure the platform from “Any CPU” to “x86”.

Step-By-Step Guide on Re-Reference COM

Step 1: Project > SMS properties SMS API 7 in VB.net-16
Step 2: Reference > Unspecified reference > Remove SMS API 7 in VB.net-17
Step 3: Project > Add Reference SMS API 7 in VB.net-18
Step 4: COM > MobitekSMSAPI7 > OK SMS API 7 in VB.net-19

 

Step-By-Step Guide on Re-Register the COM

Step 1: Login as Administrator.

Step 2: Find “MobitekSMSAPI7.dll” in “System32” folder.

Step 3: If not found then reinstall.

Step 4: If found then click on Start > Run and enter “regsvr32 mobiteksmsapi7.dll” click “OK” to manually register,

SMS API 7 in VB.net-20