Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / C#

Send Picture Message from PC to Mobile

Rate me:
Please Sign up or sign in to vote.
3.39/5 (21 votes)
4 Jul 2007CPOL5 min read 391.7K   4.8K   50   93
This article will help you to send a picture + text as SMS from PC to mobile.........using C#

Introduction

Some days ago, I was wondering whether I could send a picture from my PC to mobile? After a lot of thinking, I came to know that I could do so. This article is a sample example for you in order to send a picture to your mobile. Text and picture messages have the same method for sending, but the only difference is the length of the message. You can fit your text into one message like if you just send "hello", but it's difficult to fit a picture in one message because you have a complete format for the picture. I am using OTA format for sending pictures to my mobile phone Sony Ericsson k500i.

Background

To understand this article, you must have knowledge of how to send text SMS.

OTA

Over the Air (OTA) is an image format for mobile phones which has standard size of 72x28, etc. It has only two colors, black and white. Read this article for how to convert an image into OTA format.

Details

First of all, convert your image into OTA format and copy all its data in any file like *.txt, *.doc, etc. Here is an example for the OTA data of image.

66 66 66 66 66 66 66 66 66 99 99 99 99 99 99 99 99 99 80 00 00 00 00 00 00 00 01
40 00 00 00 60 00 E0 00 02 40 00 00 0E 90 03 10 00 02 80 00 00 31 08 0C F3 B8 01
80 00 00 40 04 11 04 44 01 40 00 00 FF FE 2F 8B 12 02 40 00 00 00 00 53 8C AA 02
80 00 00 00 00 62 89 C4 01 80 00 00 00 00 41 41 40 01 40 00 00 00 00 01 42 80 02
40 00 20 00 00 01 42 80 02 80 01 F0 00 00 00 A2 80 01 80 0F FE 00 00 00 A5 00 01
5F FF FF FF FF FE A5 7F FA 40 0A AA 00 00 00 55 00 02 82 01 50 04 40 01 5D 08 A1
88 10 24 80 00 40 FF 02 01 40 41 00 01 00 03 AB E0 02 44 00 00 08 20 0D 55 58 82
80 10 14 40 00 1A AA AC 01 80 00 00 00 00 35 55 56 01 40 01 00 00 80 6A AA AB 02
40 00 00 00 00 55 55 55 02 80 00 00 00 00 00 00 00 01 99 99 99 99 99 99 99 99 99
66 66 66 66 66 66 66 66 66 

As we know, when we send text SMS, we encode our text into PDU. So the same method will be used for the picture SMS.

PDU for Picture SMS (Encoding Picture)

The following example shows how to encode a picture SMS. The example includes a picture and a text "Test". The length of the Picture message is so long that the message must be sent as a concatenated message (in three SMS). Here is the encoded data:

First part: (length =140)

8C0B0504158A00000003010301300000045465737402010000481C0166666666
6666666666999999999999999999800000000000000001400000006000E00002
400000E900310000280000031080CF3B801800000400411044401400000FFFE2
F8B12024000000000538CAA0280000000006289C401800000000041414001400
00000001428002400020000 

Second part: (length =140)

8C0B0504158A00000003010302014280028001F0000000A28001800FFE000000
A500015FFFFFFFFFFEA57FFA400AAA0000005500028201500440015D08A18810
2800040FF0201404100010003ABE00244000008200D55588280101440001AAAA
C0180000000003555560140010000806AAAAB024000000000555555028000000
000000000199999999999999 

Third part: (length =23)

170B0504158A000000030103039999666666666666666666 

Explanation for the First Part

  • 8C length of part 1 (280/2=140(dec) and 8C(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port)
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 01 Information Element Data (sequence number of current short message)
  • 30 Identifier for version, current version is (ASCII) zero "0". If it is not "0", stop processing of the message.
  • 00 "00" <Item-length>
  • 00 Text length
  • 04 Text length
  • 54657374 "Test"
  • 02 "02" = <Item length><OTA bitmap>
  • 0100 <Item-length> value 0100(hex) = 256(dec) = 4 octets for header and the rest for OTA bitmap data
  • 00 The first byte of the bitmap must be 00 (hex); i.e., OTA bitmap header field 'number of animated icons' must hold 0, indicating that there is no animation, just a single static image.
  • 48 Width = 48(hex) = 72(dec)
  • 1C Height = 1C(hex) = 28(dec)
  • 01 The depth of the bitmap (number of grey scales)

All the rest is the image data.

Explanation for the Second Part

  • 8C length of part 2 (280/2=140(dec) and 8C(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port)
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 02 Information Element Data (sequence number of current short message)

All the rest is the image data.

Explanation for the Third Part

  • 17 length of part 3 ((48-2)/2=23(dec) and 17(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port).
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 03 Information Element Data (sequence number of current short message)

All the rest is the image data.

Now we have divided our image into a number of parts. So add the following data in the front of each part.

0051000C91xxxxxxxxxxxx00F5A7 

Explanation

  • 00 always added
  • 5100 not going to explain here
  • 0C length of phone number
  • 91 phone number format (91=international and 81=national)
  • xxxxxxxxxxxx 12 digit phone number (for example my phone number is 23216427434. write it as 292361244743)
  • 00F5 not going to explain here
  • A7 time limit (24 hours in this case)

Complete Example

SMS # 1:
0051000C913012467234F400F5A78C0B0504158A000000030103013000000
45465737402010000481C0166666666666666666699999999999999999980
0000000000000001400000006000E00002400000E90031000028000003108
0CF3B801800000400411044401400000FFFE2F8B12024000000000538CAA0
280000000006289C401800000000041414001400000000014280024000200000

SMS # 2:

0051000C913012467234F400F5A78C0B0504158A000000030103020142800
28001F0000000A28001800FFE000000A500015FFFFFFFFFFEA57FFA400AAA
0000005500028201500440015D08A188102800040FF0201404100010003AB
E00244000008200D55588280101440001AAAAC01800000000035555601400
10000806AAAAB024000000000555555028000000000000000199999999999999

SMS # 3:
0051000C913012467234F400F5A7170B0504158A0000000301030399996666
66666666666666

Send Picture SMS

The code for how to send a simple text SMS is attached with this article. Just paste your SMS PDU and send your cute picture massage. Remember that I am using a serial port for the communication.

Or

You can use Windows hyper terminal for sending your message.

Start->Programs->Accessories->Communications->HyperTerminal

  • And then use the following commands for sending SMS:
  • AT+CMGF=0 (pdu mode, use the command only first time if you have multiple SMS like in our case, three SMS.)
  • AT+CMGW=(length of pdu, for example 153 in SMS # 1)
    > write your pdu, in the end press ctrl+z and then press Enter. If it will display Ok, then succeeded. It will also display the message number.
  • AT+CMSS=(message number)

And now your message has been sent.

Future Work

I am trying to send MMS as well, using C#.

References

  • Nokia Smart_Messaging_FAQ_v2_0

History

  • 5th July, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Pakistan Pakistan
I did BS in Computer Science from Punjab University,Pakistan.

I have developed lot of Softwares and mostly interested in mathematics,image processing,AI,signal processing,mobile technology,database etc.

Currently working at Confiz Solutions as Sr.Software Engineer.

Comments and Discussions

 
GeneralRe: request Pin
Moeed Khan13-Apr-11 22:14
Moeed Khan13-Apr-11 22:14 
Jokehiiiii Pin
modi miral4-Jan-11 23:02
modi miral4-Jan-11 23:02 
Generalhiiiiiiiiiiiii Pin
sandeep1choudhary22-Oct-10 2:47
sandeep1choudhary22-Oct-10 2:47 
GeneralMy vote of 1 Pin
amershaik122-Aug-10 1:12
amershaik122-Aug-10 1:12 
Generalfor Pin
\\\\ancf,f;;f.f2-Aug-10 21:46
\\\\ancf,f;;f.f2-Aug-10 21:46 
GeneralHAI! friends Pin
Harisanju23-Jun-10 20:30
Harisanju23-Jun-10 20:30 
Generalgh Pin
surajkumar44-May-10 7:36
surajkumar44-May-10 7:36 
GeneralMy vote of 1 Pin
Santanu Biswas3-Apr-10 3:26
Santanu Biswas3-Apr-10 3:26 
GeneralRe: My vote of 1 Pin
Shakeel Mumtaz5-Apr-10 17:25
Shakeel Mumtaz5-Apr-10 17:25 
GeneralRe: My vote of 1 Pin
koyeal23-Nov-11 0:13
koyeal23-Nov-11 0:13 
Generalcontact me ! Pin
Shakeel Mumtaz27-Jan-10 19:14
Shakeel Mumtaz27-Jan-10 19:14 
Questionhow to show the name of sender instead of the mobile no Pin
amar elzaman26-Jan-10 12:24
amar elzaman26-Jan-10 12:24 
AnswerRe: how to show the name of sender instead of the mobile no Pin
suresh_kumar_s31-Mar-10 18:54
suresh_kumar_s31-Mar-10 18:54 
Jokehi Pin
sarpreet sarao2-Jan-10 3:01
sarpreet sarao2-Jan-10 3:01 
GeneralRe: hi Pin
ragavanaidu.p5-Jan-10 5:52
ragavanaidu.p5-Jan-10 5:52 
Generalgergerge Pin
chetan bhivasane9-Dec-09 6:33
chetan bhivasane9-Dec-09 6:33 
Generalhi Pin
sagarneel27-Nov-09 3:56
sagarneel27-Nov-09 3:56 
GeneralWhere i can enter my number Pin
sreeraj.a.1726-Nov-09 18:27
sreeraj.a.1726-Nov-09 18:27 
GeneralRe: Where i can enter my number Pin
waheedq24-Jan-10 4:50
waheedq24-Jan-10 4:50 
GeneralNeed help to understand the articles Pin
sreeraj.a.1726-Nov-09 18:26
sreeraj.a.1726-Nov-09 18:26 
Generalfad Pin
dj baby118-Nov-09 19:10
dj baby118-Nov-09 19:10 
GeneralSENT SMS FROM PC TO MOBILE VIA INTERNET Pin
koushik mohajon30-Oct-09 21:43
koushik mohajon30-Oct-09 21:43 
Generalsend and receive sms from pc through mobile Pin
ramitmass28-Sep-09 19:19
ramitmass28-Sep-09 19:19 
Generaltime pass Pin
dragon roy5-Sep-09 20:59
dragon roy5-Sep-09 20:59 
GeneralHi Pin
gandhis198626-Aug-09 0:16
gandhis198626-Aug-09 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.