After multiple posts I am still no further:

I am trying to synchronize email from a POP3 account programatically. In
2003 SE this uses the messaging app.

People have suggested simulating a send/receive. I have done this but this
is unreliable as after connecting, the menu item becomes Disconnect and so
one must disconnect and the Connect. Since the Disconnect may take time it is
difficult to determine when to start the Connect.

Other suggestions are to pass parameters to tmail but no one seems to know
what these parameters are.

I would prefer to use the mailtrns.dll transport as this seems to give the
most control, but I seem to be instantiating the callback incorrectly. Does
anyone know how to do this. I have tried to do this as follows:

I get the ONESTOPFACTORYFUNC and can call the IMAILSYNCHANDLER without a
problem. I cannot seem to get my callback to work. The callback calls the
correct methods within the class that I create (I can stop it in the
debugger inside the calls )but throws an exception
"Datatype Misalign" on return. If I omit the Addref method from my callback
it
calls Progess and I can see that the incoming parameters are also incorrect.
I assume that the way I create this class therefore is incorrect. I simply
instantiate the callback using new ... - Should I be doing something else as
it seems the parameters are not passed in the way the class is expecting them.

My callback class looks something like this (just the first few lines
included for brevity)

public:
CMailSyncCallBack();
~CMailSyncCallBack();

HRESULT STDMETHODCALLTYPE QueryInterface (REFIID rif, LPVOID* ppobj);
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();


MAPIMETHOD(RequestSync)(
LPCWSTR pszProfile,
DWORD cbCookie,
LPBYTE pbCookie
) ;


etc....

I instantiate the class and then call initialize like this:

CMailSyncCallBack *ms = new CMailSyncCallBack();

hr = pIMailSyncHandler->Initialize((IMailSyncCallBack *)ms,
_T("POP3"),pMsgStore);


Should I be doing this some other way as clearly the parametes are not being
passed correctly.

Jeff

Re: Synchronize Mail by Lao

Lao
Mon Apr 03 01:47:17 CDT 2006

Jeff,

I think I answered a few of your posts regarding this question. You
need to simulate a click on the Connect icon, not the Send/Receive
icon.

How frequently do you want the account to sync? You can configure
Outlook to auto-sync every 10 minutes, for example, via the Account
setup wizard, then you do not need to do anything.

Your approach of implementing IMailSyncCallBack is definitely NOT
BETTER, if not worse, than simulating a click to Outlook icons. Hereby
I omit 2000 words why :)

---
Lao K
Windows Mobile Pocket PC Smartphone Programming Hints and Tips
http://windowsmobilepro.blogspot.com