Adding a signature to a message account (setting properties on message accounts)
Hi!
For those of you with WIndows Mobile 6.1 devices, you might notice that your Activesync emails all automatically have signatures. We've gotten requests from partners wanting to do add/modify the signature to an account as well. Here is a sample function to update the signature for the Activesync account. Error checking removed in this sample code :).
#include <atlbase.h>
#include <cemapi.h>
HRESULT AddSignatureToAccount()
{
HRESULT hr;
CComPtr<IMAPITable> ptbl;
CComPtr<IMAPISession> pSession;
CComPtr<IMsgStore> pMsgStore;
// Log onto MAPI
hr = MAPILogonEx(0, NULL, NULL, 0, static_cast<LPMAPISESSION *>(&pSession));
// You can open a different message store here instead of the default
hr = pSession->OpenMsgStore(NULL, 0, NULL, NULL, 0, &pMsgStore);
SPropValue rgspv[3] = { 0 };
rgspv[0].ulPropTag = PR_CE_SIGNATURE; // signature content
rgspv[0].Value.lpszW = L"Sent from my personal Windows Mobile phone";
rgspv[1].ulPropTag = PR_CE_USE_SIGNATURE; // use the signature in newly composed emails
rgspv[1].Value.b = TRUE;
rgspv[2].ulPropTag = PR_CE_USE_SIGNATURE_REPLY_FORWARD; // use signature in replied or forwarded emails
rgspv[2].Value.b = TRUE;
// save the data the properties
hr = pMsgStore->SetProps (3, rgspv, NULL);
// Log off
pSession->Logoff(0, 0, 0);
return hr;
}
This should be a good starting point on how to set properties on message accounts as well. You can find a list of valid properties in mapitags.h. Have fun!
Comments
Anonymous
September 27, 2008
this is good for mobile programmerAnonymous
September 27, 2008
Is there any document about How to Use SDK of Windows Mobile 6.0 (doc or pdf)?Anonymous
September 30, 2008
guojing, you can download the Windows Mobile 6 SDK off microsoft.com. I don't think it's available as a .doc or pdf, but the SDK comes with help files.Anonymous
September 30, 2008
What? Write code to change the signature on an email account? I hope Windows Mobile 6.1 also allows a non programmer to change the default signature like the Backberry and Iphone does.Anonymous
September 30, 2008
Really good article. I have been following your blog for last 3 months. You have good knowledge on Mobile(cell phone) Industry and happenings. Please continue the good work. Thank you.Anonymous
October 01, 2008
SM - yes it is possible to do that via the UI. But this is more for ISVs or OEMs who may want to install their own transport, or modify existing ones.Anonymous
October 02, 2008
Thanks Jayongg. I get it now and understand the scenario when it will be useful. So HTC (just an example) could default the signature to "Sent from my HTC Diamond touch device" !Anonymous
October 07, 2008
I just switched from a BB to Windows Mobile 6.1 and was shocked to find you can't change your own signature like I could on the BB and iPhone. For how advanced WM 6.1 is, it's still missing some basic features.Anonymous
October 07, 2008
Kevin - Yes you can certainly change your email signature. Dig deeper into the options.Anonymous
October 15, 2008
How do I create new SMS account programmtically in Messaging application and use my own Message store and transport. I can create POP3 accout with DMConfigProcessXML, but when I try to create SMS account DMConfigProcessXML fails. What exacltly the SERVICETYPE would be in case of SMS. Any help is appreciated.Anonymous
October 29, 2008
The comment has been removedAnonymous
November 11, 2008
The comment has been removedAnonymous
November 19, 2008
The comment has been removedAnonymous
December 03, 2008
Maybe I'm a dummy - but can't this just be changed from within the email settings?Anonymous
December 04, 2008
I can't find the piple character either. It's not under my symbol list. I'm using a MOTO Qc running Windows Mobile 6.1Anonymous
December 04, 2008
The comment has been removedAnonymous
May 03, 2009
I am a student from temasek poly. I have a huge query that i am struggling. I am doing a project on a HTC tytn 2 phone. May i ask how could I actually include a .cs file with a .vb file into same project? Is there any dll file needed to add for reference? I wanted to click a button from a from in .vb. Then is there any specific codes to access a .cs file after clicking the button? The .cs file i have enable it to direct access to the HTC tytn 2 camera. Hope to hear from your reply soon. Chiu wen, zion_purrfectionist@hotmail.com