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!