|
|
Comments and Discussions
|
|
 |

|
You should have no problems running this on win2k with outlook 2k.
The data received from outlook will be simply text, html or richtext. You should be able to sling that straight into a database as far as im aware.
|
|
|
|

|
How can I get events from SyncObjectEvent?
Thanks.
|
|
|
|
|

|
Hi,
If you look in the outlook object model ApplicationEvents properties you will see that above NewMail() function there is an ItemSend() function that receives an IDispatch* Item object. Im assuming this is a pointer to the mail item being sent, as ive not had the chance to test this. Its hex value btw is f002.
To get a simple notification of the event you need to implement something like the following in your STDMETHODIMP CAppEventListener::Invoke function:
case 0x0000f002: // ItemSend()
if(pDispParams->cArgs !=2)
return E_INVALIDARG;
else
{
HandleItemSend();
}
|
|
|
|

|
Hi,
This is DKDS.Naidu. I am developing ATL COM Addin for Microsoft OUTLOOK. I want to add some message to original message after send a mail. I want to get send button events in ATL COM. How?
Thanks in Advance,
DKDS.Naidu
|
|
|
|

|
I used the code for a project I did and got some non-fatal error messages when unloading my application in the debug screen when I unloaded Outlook prior to unloading my application. The fix was to do a release on the connection point in DetachFromSource:
STDMETHODIMP CAppEventListener::DetachFromSource()
{
HRESULT hr = S_OK;
if (m_pConnectionPoint != NULL){
m_pConnectionPoint->Unadvise( m_dwConnection );
m_pConnectionPoint->Release() ;
m_pConnectionPoint = NULL;
}
return hr;
}
Otherwise the code works great!
|
|
|
|

|
Hi Zebbedi,
Thanks for your article.
I am attempting to modify your code to detect when an attachment has been openned. Under the MailItem interface there is a set of events called ItemEvents uuid(0006303A-0000-0000-C000-000000000046), that has an event type called AttachmentRead id(0x0000f00d).
You have included all the header files in your code example, so is the only other step to change from the ApplicationEvent that you are listening to to change the value associated with IID_ApplicationEvents to the value listed above?
const IID IID_ApplicationEvents =
{0x0006303A,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
I've tried doing that, but the method attaching to the event source fails:
/****************************************************************
* AttachToSource -- This method attaches to an event source.
****************************************************************/
STDMETHODIMP CAppEventListener::AttachToSource
( IUnknown* pEventSource )
{
HRESULT hr = S_OK;
IConnectionPointContainer* pCPC = NULL;
hr = pEventSource->QueryInterface( IID_IConnectionPointContainer,
(void**)&pCPC );
if (SUCCEEDED(hr)){
hr = pCPC->FindConnectionPoint( IID_ItemEvents,
&m_pConnectionPoint );
if (SUCCEEDED(hr)) //???FAILURE HERE
{
OutputDebugString("Connection to Event Source\n");
hr = m_pConnectionPoint->Advise( this, &m_dwConnection );
}
pCPC->Release();
}
return hr;
I'm pretty much a newbie here. Is there something I'm missing to extend this approach to listen to any event?
Thanks,
Harry
|
|
|
|

|
Hullo..
How would one go about getting the contents of the newly arrived message in HandleNewMail ?
Arnar
|
|
|
|

|
Arnar,
Thanks for your post. The following code will help you retrieve a mail item from your inbox. Theres alot to be aware of though unfortunately with the outlook object model. For example, the following will scan the "Inbox" folder, so if the user has extra folders you need to be aware of these as well.
CApplication app;
CNameSpace ns;
CFolders fldrs;
CItems itms;
CMAPIFolder mpfldr;
CMailItem mlitem;
// Start Outlook and get Application object.
if( !app.CreateDispatch("Outlook.Application") )
{
AfxMessageBox("Cannot start Outlook and get Application object.");
return;
}
else
{
ns = app.GetNamespace("MAPI");
fldrs = ns.GetDefaultFolder( olFolderInbox );
mpfldr = ns.GetDefaultFolder( olFolderInbox );
itms = mpfldr.get_Items();
mlitem = itms.GetFirst();
AfxMessageBox( mlitem.get_Body() );
}
zebbedi
|
|
|
|

|
On the last fldrs = ns.GetDefaultFolder( olFolderInbox ); and
mpfldr = ns.GetDefaultFolder( olFolderInbox ); lines, the constant "olFolderInbox" is used to identify the Inbox folder. Although VBA knows what this constant means, VBScript will not know understand "olFolderInbox" since it has not been defined in this script. To correct the code so that it runs under VBScript, we must locate the value of olFolderInbox.
The easiest way to locate the value of olFolderInbox is to start the VBA application: Excel in the example above. The basic steps required to locate the value of the "olFolderInbox" constant with Excel 97 or 2000 are as follows (the exact instructions may vary depending on the specific circumstances):
Start the VBA editor in Excel by pressing ALT-F11, then choose Tools... References from the Excel VBA menu bar.
Find the Microsoft Outlook object library and check it off on the list. Click OK.
Press F2 to launch the object browser.
From the dropdown menu up top, select the Outlook object library.
In the left pane of the object browser, click globals which should be at the top of the list.
In the right pane of the object browser, locate the value olFolderInbox and click on it.
Look at the value of this constant in the bottom pane of the object browser and notice that it is 6.
Since olFolderInbox = 6, the VBScript compatible version of the code above would have the last line read:
Set olookEMailFolder = _
olookNameSpace.GetDefaultFolder(6)
Another solution is to define the constant by adding the lines
Dim olFolderInbox
olFolderInbox = 6
--
Thomas
Programming is not an end in itself but only a means to an end
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
How to implement Outlook event sinks to alert your application when new mail has been received.
| Type | Article |
| Licence | |
| First Posted | 29 May 2003 |
| Views | 97,525 |
| Bookmarked | 41 times |
|
|