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 Post9 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

  5. magnus | Apr 14, 2009 | Reply

    Hi!
    I’m using an SMS Gateway to send texts, posting to a web service through http. If I post a vcal message, it is still sent as a normal text and the phone reads it as normal text. Do you have any idea how I can make it send a vcal and not just a normal text message?

  6. Glossicblinna | May 27, 2009 | Reply

    My friend just tell me and I can’t believe it, Mike’s daughter are dead so tragedy and so sad. I am a big fan of him, he is a great guy, best boxer – crazy little bet but every body know him and like him.

  7. 1 | Jun 2, 2009 | Reply

    Try appending an UDH to your message. vCard UDH Header usually is 06050423F40000

  8. ApepAfteltmiZ | Jul 6, 2009 | Reply

    It is a lot of talking about M. Jacksondead, it’s a very sad for me because I love his muai, I still didn’t believe in hs dead. Hi waas a definitely king of ‘Pop’.

  9. Esteban | Oct 15, 2009 | Reply

    Hi. I tried to use this code with Nokia 5200 and Samsung X-426 but the code donĀ“t work.

    I need help please !

    I use PortMon to view COM communications.
    Results with Samsung X-426:
    Send commands but the modem not respond. If I connect with Hyperterminal, the modem repospond normally.

    Results with Nokia 5200:
    Every commands returns ERROR

    Thanks.

Sorry, comments for this entry are closed at this time.