Hi all (and Peter specially:) )
I am able to create the signature of a custom account programmatically
using the PR_CE_SIGNATURE and PR_CE_USE_SIGNATURE properties.
So, during the installation of my .cab file in the setup process, I
create the mail account and then I start the signature process. When
ended, I can see the account and the signature properly set but if I
create a new email I cannot see the signature in the mail!!
But if I go in the mail option, I go in the page of the signature and
without changing anything I press Done, after that I can see the
signature in the mail :(
Is there anything that I miss? Is there some sort of flush() or
"StorePersistentlyAndUseIt"...
I add my code...
Thanks for help
Marco
wchar_t* setMailAccountSignature(const char* signature = NULL) {
HRESULT hr;
IMAPISession * pSession = NULL;
IMAPITable* pTable = NULL;
SRowSet* psrs = NULL;
IMsgStore* pStore = NULL;
BOOL accountFound = FALSE;
SPropValue* rgprops = NULL;
wchar_t* ret = NULL;
bool msgset = false;
// First log on to the store.
hr = MAPILogonEx (NULL, NULL, NULL, NULL, &pSession);
EXIT_ON_FAILED (hr);
// Get the message stores table
hr = pSession->GetMsgStoresTable (MAPI_UNICODE, &pTable);
EXIT_ON_FAILED (hr);
hr = pTable->SetColumns((LPSPropTagArray)&Columns, 0);
EXIT_ON_FAILED(hr);
while (!msgset){
// Get a row
hr = pTable->QueryRows (1, 0, &psrs);
EXIT_ON_FAILED (hr);
// Did we hit the end of the table?
if (psrs->cRows != 1) {
break;
}
//
// the display name is the name of the account.
//
wchar_t* displayName =
psrs->aRow[0].lpProps[eePR_DISPLAY_NAME].Value.lpszW;
//
// The name of the MessageStore that we use for the own Transport
//
if (wcscmp(displayName, "MyAccount") == 0) {
accountFound = TRUE;
// Open this message store
hr = pSession->OpenMsgStore (NULL,
psrs->aRow[0].lpProps[0].Value.bin.cb,
(ENTRYID *) psrs->aRow[0].lpProps[0].Value.
bin.lpb, NULL, 0, &pStore);
EXIT_ON_FAILED (hr);
SPropValue rgprops[2] = {0};
rgprops[0].ulPropTag = PR_CE_SIGNATURE;
rgprops[0].Value.lpszW = TEXT("my Signature");
rgprops[1].ulPropTag = PR_CE_USE_SIGNATURE;
rgprops[1].Value.b = true;
hr = pStore->SetProps(2, rgprops, NULL);
EXIT_ON_FAILED (hr);
}
// Clean up
MAPIFreeBuffer (rgprops);
FreeProws (psrs);
rgprops = NULL;
psrs = NULL;
RELEASE_OBJ (pStore);
}
if (accountFound == FALSE) {
LOG.error("No " PROVIDER " account found");
}
FuncExit:
MAPIFreeBuffer (rgprops);
FreeProws (psrs);
RELEASE_OBJ (pStore);
RELEASE_OBJ (pTable);
RELEASE_OBJ (pSession);
return ret;
}