have quoted the code below. Hope that anyone can give an idea to make it
work in the pocket PC/Smartphone platform
Hi,

Here is a code to catch notifications on ppc using imapisession::Advise

But it doesn't work and we never get notified when new mails comes on the
device.

can anyone help out to detect the cause and how to get notifications on a
ppc/smartphone.

thanks.


Catch Email sent Event From Device - Jeffrey Min [MSFT]
12-Mar-07 04:17:16

Kamii,

To use IMAPISession::Advise, you must create a class that implements the
IMAPIAdviseSink interface. A basic understanding of COM (Component Object
Model) programming is helpful. You need to implement the base IUnknown
functions (QueryInterface, AddRef, Release), as well as the
IMAPIAdviseSink::OnNotify function.

class CMySink :
public IMAPIAdviseSink
{
public:
// IUnknown
HRESULT QueryInterface(REFIID iid, void **ppvObject);
ULONG AddRef();
ULONG Release();

// IMAPIAdviseSink
ULONG OnNotify(ULONG cNotif, LPNOTIFICATION lpNotifications);
};

At the start of your application, start a MAPI session and register your
advise sink using the Advise function.

void CMyApp::Initialize()
{
// Start MAPI session
MAPILogonEx(0, NULL, NULL, 0, (IMAPISession**)&m_pSession);

// Create advise sink object
m_pAdviseSink = new CMySink();

// Register the advise sink for object moved notifications
m_pSession->Advise(0, NULL, fnevObjectMoved,
(LPMAPIADVISESINK)m_pAdviseSink, &m_ulAdviseConnection);
}

Now that your advise sink is registered, the OnNotify function will be
called every time there is an object moved notification. In the OnNotify
function, you can check for only those messages you are interested in (i.e.
check if it is a message being moved into the Sent Items folder).

Hope this helps.

--
Jeffrey Min
Software Development Engineer
Microsoft Corp.

Re: help to catch notifications on ppc using imapisession::Advise by Peter

Peter
Sat Dec 08 04:28:57 PST 2007

The code only registers to received notifications when items move. You need
to supply the correct flags to get new mail notifications also.

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

"M. Rajesh" <msmrajesh@yahoo.co.in> wrote in message
news:EF1A0C91-A56D-4651-B857-C1A8EEF619EC@microsoft.com...
> have quoted the code below. Hope that anyone can give an idea to make it
> work in the pocket PC/Smartphone platform
> Hi,
>
> Here is a code to catch notifications on ppc using imapisession::Advise
>
> But it doesn't work and we never get notified when new mails comes on the
> device.
>
> can anyone help out to detect the cause and how to get notifications on a
> ppc/smartphone.
>
> thanks.
>
>
> Catch Email sent Event From Device - Jeffrey Min [MSFT]
> 12-Mar-07 04:17:16
>
> Kamii,
>
> To use IMAPISession::Advise, you must create a class that implements the
> IMAPIAdviseSink interface. A basic understanding of COM (Component Object
> Model) programming is helpful. You need to implement the base IUnknown
> functions (QueryInterface, AddRef, Release), as well as the
> IMAPIAdviseSink::OnNotify function.
>
> class CMySink :
> public IMAPIAdviseSink
> {
> public:
> // IUnknown
> HRESULT QueryInterface(REFIID iid, void **ppvObject);
> ULONG AddRef();
> ULONG Release();
>
> // IMAPIAdviseSink
> ULONG OnNotify(ULONG cNotif, LPNOTIFICATION lpNotifications);
> };
>
> At the start of your application, start a MAPI session and register your
> advise sink using the Advise function.
>
> void CMyApp::Initialize()
> {
> // Start MAPI session
> MAPILogonEx(0, NULL, NULL, 0, (IMAPISession**)&m_pSession);
>
> // Create advise sink object
> m_pAdviseSink = new CMySink();
>
> // Register the advise sink for object moved notifications
> m_pSession->Advise(0, NULL, fnevObjectMoved,
> (LPMAPIADVISESINK)m_pAdviseSink, &m_ulAdviseConnection);
> }
>
> Now that your advise sink is registered, the OnNotify function will be
> called every time there is an object moved notification. In the OnNotify
> function, you can check for only those messages you are interested in
> (i.e.
> check if it is a message being moved into the Sent Items folder).
>
> Hope this helps.
>
> --
> Jeffrey Min
> Software Development Engineer
> Microsoft Corp.
>
>
>
>
>
>