Go Back   Technology Questions > Hardware Questions > Electronics > Smartphones

Smartphones This is the Microsoft General Public Smartphones Newsgroup.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 04-03-2008, 05:10 AM
Magi
Tablet PC Guest
 
Posts: n/a
Email Signature programmatically: part 2

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;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 04-03-2008, 05:10 AM
Xploder HD Movie Player for PS3. Manage, convert and transfer media files between the PC and PS3.
  #2 (permalink)  
Old 04-03-2008, 05:30 AM
Peter Foot
Tablet PC Guest
 
Posts: n/a
Re: Email Signature programmatically: part 2

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

"Magi" <magi@funambol.com> wrote in message
news:elV8$uYlIHA.4480@TK2MSFTNGP03.phx.gbl...
> 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;
> }


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 04-03-2008, 08:40 AM
Magi
Tablet PC Guest
 
Posts: n/a
Re: Email Signature programmatically: part 2

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
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 04-03-2008, 08:40 AM
Magi
Tablet PC Guest
 
Posts: n/a
Re: Email Signature programmatically: part 2

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
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 04-04-2008, 12:20 AM
Magi
Tablet PC Guest
 
Posts: n/a
Re: Email Signature programmatically: part 2

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
E-mail signature programmatically Magi Pocket PC General 3 03-27-2008 10:10 AM
E-mail signature programmatically Magi Smartphones 3 03-27-2008 10:10 AM
Email spell check with signature Schnapps Windows Vista 14 01-16-2008 06:50 PM
Logo in Signature showing as an attachment on received email colsa546 Microsoft Office 1 10-24-2007 12:30 AM
graphics in email signature miclew Microsoft OneNote 1 07-17-2007 05:40 PM


All times are GMT -8. The time now is 05:29 PM.


2003 - 2008 All Rights Reserved. Technology Questions

SEO by vBSEO 3.1.0