Quick Messaging API (MAPI) Sample


I heard someone say they wished it were possible to create a speed dial entry for text messaging in Windows Mobile. As most of you might know, text messaging is not a standalone app - it's just another account within the Messaging client, which also supports Outlook and other email accounts (Hotmail, POP3 etc).

So how do you create a speed dial entry that always goes directly into Text Messages (and not any of the other types of messaging accounts?)

I decided to write a tiny app that does this. My first thought was to launch a command line like Inbox.exe with some special parameter that would force it into the Text Messages account. The downside of doing something like that is the .exe name/path might change in the future and the command line parameter is probably undocumented.

I then remembered reading about some APIs that let you interact with the messaging client. I found one that did exactly what I needed: MailSwitchToAccount.

Sweet! With this documented API, the task becomes very easy and immune from breaking in future versions of Windows Mobile. The entire program is as follows:

#include <windows.h>
#include <cemapi.h>

int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
{
    MailSwitchToAccount(_T("SMS"), MCF_ACCOUNT_IS_NAME);
    return 0;
}

As you can see, it is very easy to write an app that launches a specific account within the Messaging app. The user can then create a shortcut to this app and launch it from speed dial or the Start menu. For more MAPI functions that might be useful to you, click here. (Note: you will need to link with cemapi.lib to use these functions).

-Mel Sampat


Comments (15)
  1. ali says:

    please help me

    i have one mio A501 with windows mobile 5.0

    i have one problem my windows language is france ,

    please help to change this language to english.

    thanks

    my email is ali_1360@yahoo.com

  2. bluejeans says:

    I can send/receive text MMS, but I cannot include MMS attachments like images, vdo and snd files.

    I already do the same things on another smartphone platform, but have not yet resolved this problem in Windows Mobile.

    Please help with some sample code.

    email me: jeans0039@gmail.com

  3. Bruce says:

    I am writing a mobile app (currently testing on 5.0) that needs to maintain a persistent reference to a message.  I’ve used MAPI to obtain the PR_ENTRYID of both the message store and of the message.  The problem I encounter, is I can’t later directly use these ID’s with OpenEntry().  Doing so, crashes in cemapi.dll.  However, I can request a table of message stores, iterate through the list and compare each entry’s PR_ENTRYID with the PR_ENTRYID I perviously obtained (using CompareEntryIDs()) and find the correct Message Store.  I can then iterate through all of it’s folders and subfolder looking for a message whose PR_ENTRYID compares the same (again using CompareEntryIDs()).  This is NOT an optimal solution.  Is the OpenEntry() crash a known problem, or am I perhaps doing something wrong?  

    By the way, I can use the saved PR_ENTRYID for the message and call MailDisplayMessage() and it quickly displays the correct message!!!  It doesn’t even need the PR_ENTRYID of for the storage!!!.  Is there a way to do something equivalent that gives me a way to request properties for the referenced email?

    I would appreciate any help. Thanks.

  4. Carl says:

    I know this is not the correct article to be asking this in but I can not find any other’s that are current. I am looking for some help in using the apis for Wap protocal and push messages. I am looking to implement the PushRouter(apis) and  have looked at the ‘fileclient’ example that ships with the Windows Mobile 6 SDK but the sample falls short of how to implment or at least test the PushRouter_GetMessage section. If there is anyone that can point me to the correct forum/person/article that would be more helpful I would appreciate it.

    Thanks for reading this.

  5. Santiago says:

    are there APIs for sending and receiving MMS messages?

  6. Tim says:

    Hi,

    I met a problem that is similar with yours.

    I tried to create some shortcuts on homescreen that goes directly into "Missed Call", "Incoming Call" and "Outgoing Call" page.

    My first thought was also to launch a command line like clog.exe with some special parameter that would force it into the specified page.

    But parameters of clog.exe are also undocumented.

    Does anyone know the usage of clog.exe parameters ,or there is any API to do this?

    My email: timl@wire.cs.nthu.edu.tw

    Thanks in advance.

    Best Regards,

    Tim

  7. zeft elteen says:

    hi man

    where r u , iam wait for u now to internet , please harry up.

  8. Meadower says:

    Can somebody post the .exe or .cab for the program shown above? Also, it would be great of somebody could whip up an additional version that directly opened GMail (vs text messaging). Thanks in advance.

  9. Rakesh says:

    Hi,

    I’m trying to make an app that automatically sets up a specific email service.  My app is similar to the "Setup Up Email" app that ships with WM which allows you to quickly setup for example a Yahoo! email account, and when it does, it sets up a Yahoo! icon that shows in the in the mail accounts page.

    I’m trying to find out how to put my own icon for my mail service the same way that that app does it for Yahoo! and MSN mail – Anyone knows where this icon is or how to replace it with my own?

    Thanks!

  10. ivan says:

    please help me

    i have one mio A501 with windows mobile 5.0

    i have one problem my windows language is Greece ,

    please help to change this language to english.

    thanks

    my email is akorda@abv.bg

  11. igor says:

    please help me

    i have one mio A501 with windows mobile 5.0

    i have one problem my windows language is greece,

    please help to change this language to english.

    thanks

    formatpsih@yahoo.com

  12. arsi says:

    please please please help me

    i have one mio A501 with windows mobile 5.0

    i have one problem my windows language is greece,

    please help to change this language to english.

    thanks

    rc-_-dj@hotmail.com

  13. rootx says:

    Help me,

    I can’t find API Send MMS on windows mobile,

    Please tell me how to programming send MMS on Windows Mobile.

    Thanks

    my mail ducnt.cc@gmail.com

  14. beauty says:

    please how to change my mio a501 language from greek to english

Comments are closed.

Skip to main content