Decode or Convert .VMG files to .TXT (Using C#)

See update below.

I used to have a Nokia phone, and backed up SMS messages using Nokia's PC Suite software. However, the messages were saved as .vmg files, which were encoded in unicode. Here's an example of how to decode a single .vmg file to a text file using C#. Converting the .vmg files to simple text files makes it a lot more convenient to read the messages later on. Of course, this isn't the only way to decode the files, and can be implemented with other languages.

 1 private void DecodeVMG()
2 {
3 FileInfo finfo = new FileInfo("SMSmessage.vmg");
4 FileStream stream = new FileStream(finfo.FullName,
5 FileMode.Open, FileAccess.Read);
6 BinaryReader br = new BinaryReader(stream);
7 byte[] data = br.ReadBytes((int)finfo.Length);
8 string decodedstring =
9 Encoding.Unicode.GetString(data).Trim();
10 using (StreamWriter writer
11 = new StreamWriter("DecodedMessage.txt"))
12 {
13 writer.WriteLine(decodedstring);
14 }
15 br.Close();
16 stream.Close();
17 }

Below is a sample output.

BEGIN:VMSG
VERSION:1.1
X-IRMC-STATUS:READ
X-IRMC-BOX:INBOX
X-NOK-DT:20070903T175600Z
X-MESSAGE-TYPE:DELIVER
BEGIN:VCARD
VERSION:3.0
N:
TEL:+19090000000
END:VCARD
BEGIN:VENV
BEGIN:VBODY
Date:03.09.2007 17:56:00
This is a test Message!
END:VBODY
END:VENV
END:VMSG

UPDATE (June 28, 2008): I noticed a large number of visits for this page, and I’m wondering if anyone will be interested if I created a simple program to do this conversion. I’ll be glad to hear your thoughts. Just leave a comment. Thanks!


Tags: .NET, C#, Code, Encoding, Nokia, SMS, Unicode, Windows

Bookmark and Share

Comments