Click here to get back home

Email Signature programmatically: part 2

 HomeNewsGroups | Search | About
 microsoft.public.smartphone    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Email Signature programmatically: part 2 Magi 04-03-2008
Posted by Magi on April 3, 2008, 9:07 am
Please log in for more thread options
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] = ;

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;
}

Posted by Peter Foot on April 3, 2008, 9:26 am
Please log in for more thread options
Just a thought, but you could try closing the Messaging application when you
run your installer and the launching it again at the end so it will pick up
the new settings. Either send a WM_CLOSE to the main window or if that fails
terminate the tmail.exe process.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

> 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] = ;
>
> 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;
> }


Posted by Magi on April 3, 2008, 12:33 pm
Please log in for more thread options
Hi, thanks for the quick reply.
I tried it but it doesn't work. I close the tmail.exe process usign also
the Windows CE process viewer but nothing changes. I re-openend the mail
several times but I cannot see the signature.
Actually I'm quite lost...

Marco


Peter Foot ha scritto:
> Just a thought, but you could try closing the Messaging application when
> you run your installer and the launching it again at the end so it will
> pick up the new settings. Either send a WM_CLOSE to the main window or
> if that fails terminate the tmail.exe process.
>
> Peter
>

Posted by Magi on April 3, 2008, 12:33 pm
Please log in for more thread options
Hi, thanks for the quick reply.
I tried it but it doesn't work. I close the tmail.exe process usign also
the Windows CE process viewer but nothing changes. I re-openend the mail
several times but I cannot see the signature.
Actually I'm quite lost...

Marco


Peter Foot ha scritto:
> Just a thought, but you could try closing the Messaging application when
> you run your installer and the launching it again at the end so it will
> pick up the new settings. Either send a WM_CLOSE to the main window or
> if that fails terminate the tmail.exe process.
>
> Peter
>

Posted by Magi on April 4, 2008, 4:12 am
Please log in for more thread options
Hi,
I found the solution :)
also the property PR_CE_USE_SIGNATURE_REPLY_FORWARD must be set.

rgprops[0].ulPropTag = PR_CE_SIGNATURE;
rgprops[0].Value.lpszW = (wchar_t*)sign.c_str();

rgprops[1].ulPropTag = PR_CE_USE_SIGNATURE;
rgprops[1].Value.b = true;

rgprops[2].ulPropTag = PR_CE_USE_SIGNATURE_REPLY_FORWARD;
rgprops[2].Value.b = true;

hr = pStore->SetProps(3, rgprops, NULL);

Settings this one too, when I open the account for the first time and I
write an email I can see the signature properly...

Cheers and thanks
Marco

Magi ha scritto:
> Hi, thanks for the quick reply.
> I tried it but it doesn't work. I close the tmail.exe process usign also
> the Windows CE process viewer but nothing changes. I re-openend the mail
> several times but I cannot see the signature.
> Actually I'm quite lost...
>
> Marco
>
>
> Peter Foot ha scritto:
>> Just a thought, but you could try closing the Messaging application
>> when you run your installer and the launching it again at the end so
>> it will pick up the new settings. Either send a WM_CLOSE to the main
>> window or if that fails terminate the tmail.exe process.
>>
>> Peter
>>

Similar ThreadsPosted
E-mail signature programmatically March 27, 2008, 12:48 pm
Treo 700w email signature does not appear when replying to email March 7, 2006, 1:40 pm
need 7100t part August 31, 2005, 10:16 pm
No Digital Signature October 29, 2005, 3:05 pm
Outlook signature July 17, 2007, 3:59 pm
how to adjust volume level programmatically? August 10, 2006, 10:49 pm
How to programmatically set the phone ringing mode? April 24, 2007, 12:07 pm
Save any part of your favorite mp3s to MMF, AMR, MIDI ringtone May 16, 2006, 3:53 pm
I Give Up on Vista-Smartphone Sync--Anybody Know a Good 3rd Part A June 2, 2007, 12:56 pm
How to programmatically react on incoming phone calls? April 18, 2007, 11:28 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap