RSS Feed for This PostCurrent Article

Send vCard, vCalendar and WAP Push Message


Download Source Code

In the previous blogs, I showed you how to retrieve phone settings, send and receive SMS, dial a phone number, and answer or hang up a phone call using the .NET SMS library. Now I am going to show you how to send vCard, vCalendar and WAP push message. Take note that sending WAP push message is not fully tested and it may not work in your environment.

phonemsg.jpg

vCard is nothing but a SMS in a specific format. Try using the sample project attached in this article to send a vCard. You should be able to see the vCard message format displayed in the text box after you sent it. If the receiving mobile phone supports vCard, then it can be saved straight away into the contact list.

//SCKE2 BEGIN:VCARD
VERSION:2.1
N:Magic Source;;;;
ORG:;
EMAIL;INTERNET:[email protected]
TEL;PREF;CELL;VOICE:0192292309
REV:00010101T000000Z
END:VCARD

Same thing goes for vCalendar, which is also SMS in a specific format.

//SCKE4 BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:
SUMMARY:Test Summary
ORGANIZER:Test Org
LOCATION:
DTSTART:00010101T000000Z
DTEND:00010101T000000Z
DTSTAMP:20061214T141408Z
DESCRIPTION:
END:VEVENT
END:VCALENDAR

For WAP push message the message format is more complicated and it is not fully tested on all handsets for the SMS library. Basically for a WAP push message a link and a message are required. You can refer the sample code below.

Imports ATSMS
Imports ATSMS.SMS

Public Class MainForm

Private WithEvents oGsmModem As New GSMModem

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CheckForIllegalCrossThreadCalls = False
End Sub

Private Sub btnPhone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click

If cboComPort.Text = String.Empty Then
MsgBox(“COM Port must be selected”, MsgBoxStyle.Information)
Return
End If

oGsmModem.Port = cboComPort.Text

If cboBaudRate.Text <> String.Empty Then
oGsmModem.BaudRate = Convert.ToInt32(cboBaudRate.Text)
End If

If cboDataBit.Text <> String.Empty Then
oGsmModem.DataBits = Convert.ToInt32(cboDataBit.Text)
End If

If cboStopBit.Text <> String.Empty Then
Select Case cboStopBit.Text
Case “1″
oGsmModem.StopBits = Common.EnumStopBits.One
Case “1.5″
oGsmModem.StopBits = Common.EnumStopBits.OnePointFive
Case “2″
oGsmModem.StopBits = Common.EnumStopBits.Two
End Select
End If

If cboFlowControl.Text <> String.Empty Then
Select Case cboFlowControl.Text
Case “None”
oGsmModem.FlowControl = Common.EnumFlowControl.None
Case “Hardware”
oGsmModem.FlowControl = Common.EnumFlowControl.RTS_CTS
Case “Xon/Xoff”
oGsmModem.FlowControl = Common.EnumFlowControl.Xon_Xoff
End Select
End If

Try
oGsmModem.Connect()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
Return
End Try

Try
oGsmModem.NewMessageIndication = True
Catch ex As Exception

End Try

btnSendvCard.Enabled = True
btnSendvCalendar.Enabled = True
btnSendWapPush.Enabled = True
btnDisconnect.Enabled = True

MsgBox(“Connected to phone successfully !”, MsgBoxStyle.Information)

End Sub

Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
Try
oGsmModem.Disconnect()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

btnSendvCard.Enabled = False
btnSendvCalendar.Enabled = False
btnSendWapPush.Enabled = False
btnDisconnect.Enabled = False
btnConnect.Enabled = True

End Sub

Private Sub btnSendvCard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendvCard.Click
If txtPhoneNumber.Text.Trim = String.Empty Then
MsgBox(“Phone number must not be empty”, MsgBoxStyle.Critical)
Return
End If

Dim v As New vCard
v.LastName = “Magic Source”
v.Emails = New vCard.vEmails()
v.Emails.Add(New vCard.vEmail([email protected]))
v.Telephones = New vCard.vTelephones
v.Telephones.Add(New vCard.vTelephone(“0192292309″, vCard.vLocations.CELL, vCard.vPhoneTypes.VOICE, True))
txtMsg.Text = v.ToString
Try
Dim msgId As String = oGsmModem.SendSMS(txtPhoneNumber.Text, v.ToString)
MsgBox(“vCard sent. Message id is “ + msgId)
Catch ex As Exception
MsgBox(ex.Message & “. Make sure your SIM memory is not full.”, MsgBoxStyle.Critical)
End Try
End Sub

Private Sub btnSendvCalendar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendvCalendar.Click
If txtPhoneNumber.Text.Trim = String.Empty Then
MsgBox(“Phone number must not be empty”, MsgBoxStyle.Critical)
Return
End If

Dim v As New vCalendar
Dim vE As New vCalendar.vEvent
vE.DTStart = New Date
vE.DTEnd = New Date
vE.Organizer = “Test Org”
vE.Summary = “Test Summary”
v.Events.Add(vE)
txtMsg.Text = v.ToString
Try
Dim msgId As String = oGsmModem.SendSMS(txtPhoneNumber.Text, v.ToString)
MsgBox(“vCalendar sent. Message id is “ + msgId)
Catch ex As Exception
MsgBox(ex.Message & “. Make sure your SIM memory is not full.”, MsgBoxStyle.Critical)
End Try
End Sub

Private Sub btnSendWapPush_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendWapPush.Click
If txtPhoneNumber.Text.Trim = String.Empty Then
MsgBox(“Phone number must not be empty”, MsgBoxStyle.Critical)
Return
End If
Dim href As String = “http://atopensource.110mb.com”
Dim text As String = “Share your mobile today”
Dim body As String = New WapPushMessage(href, text).ToString
oGsmModem.Encoding = ATSMS.Common.EnumEncoding.Hex_Message
Try
Dim msgId As String = oGsmModem.SendSMS(txtPhoneNumber.Text, body)
MsgBox(“Message sent. Message id is “ + msgId)
Catch ex As Exception
MsgBox(ex.Message & “. Make sure your SIM memory is not full.”, MsgBoxStyle.Critical)
End Try
End Sub
End Class


Trackback URL


RSS Feed for This Post4 Comment(s)

  1. Prashant | Oct 30, 2007 | Reply

    Is it possible to get list of Contacts, if yes how to implement that?

  2. Shawn Glenn | Apr 21, 2008 | Reply

    peribulbar outscream sussultorial hexasepalous thumping blurredness palaestrics strychninism
    Pleasant View Bed & Breakfast
    http://digsix.com/

  3. Pwhndvve | Aug 9, 2008 | Reply

    Rimsky went look closer buy cytotec then announced estivities.

  4. shrirams1 | Oct 13, 2008 | Reply

    Hi
    I wanna help to find out bluetooth device using dotnet technoly..
    Can any one help me

RSS Feed for This PostPost a Comment