Click here to Skip to main content
15,891,424 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAccessing resources Pin
0v3rloader16-Jul-04 6:46
0v3rloader16-Jul-04 6:46 
GeneralRe: Accessing resources Pin
David Crow16-Jul-04 7:06
David Crow16-Jul-04 7:06 
Questionhow to receive outgoing message Pin
Anton Zarubin16-Jul-04 5:37
Anton Zarubin16-Jul-04 5:37 
GeneralRe: how to receive outgoing message Pin
David Crow16-Jul-04 7:02
David Crow16-Jul-04 7:02 
GeneralRe: how to receive outgoing message Pin
Eugene Grudina16-Jul-04 8:27
sussEugene Grudina16-Jul-04 8:27 
AnswerRe: how to receive outgoing message Pin
Antti Keskinen16-Jul-04 8:22
Antti Keskinen16-Jul-04 8:22 
GeneralRe: how to receive outgoing message Pin
Anton Zarubin17-Jul-04 0:36
Anton Zarubin17-Jul-04 0:36 
GeneralRe: how to receive outgoing message Pin
Antti Keskinen17-Jul-04 5:30
Antti Keskinen17-Jul-04 5:30 
Well, in order to get you going, here's a complete code-paste of a switch statement that catches an outgoing mail message and displays it in a message box:
// At the start of the file, add the following line
// IMailItem interface identifier
const IID IID_IMailItem  = 
{0x00063034,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};<DIV>

.
.
.<DIV>

switch(dispIdMember)
{
case 0x0000f002:        // ItemSend
	{
		// First, find the IDispatch interface parameter
		IDispatch* pDisp = NULL;<DIV>			
		for ( UINT nIndex = 0; nIndex < pDispParams->cArgs; nIndex++ )
		{
			// Check if the VARIANTARG is type VT_DISPATCH
			if ( pDispParams->rgvarg[nIndex].vt == VT_DISPATCH )
			{
				// Yup, so copy
				pDisp = pDispParams->rgvarg[1].pdispVal;
				break;
			}
		}<DIV>
			
		// See if it is a mail item. It is if it supports _MailItem interface
		IUnknown* pMail; 
		HRESULT hr = pDisp->QueryInterface( IID_IMailItem, (void**)&pMail );<DIV>

		if ( SUCCEEDED(hr) )
		{
			CMailItem MailItem;
			MailItem.AttachDispatch( pDisp );<DIV>

			CString csBody = MailItem.get_Body();<DIV>

			AfxMessageBox( (LPCTSTR) csBody );
		}<DIV>

		pMail->Release(); pMail = NULL;<DIV>

		break;
	}
}
I've tested this with my own Outlook XP (2002), and it captures outgoing mail messages correctly, and ignores other outgoing items. Copy the interface identifier to the start of the code file, and replace your switch statement with this code piece. Add a breakpoint, start Outlook, run the app in debug mode and observe the results. Although it works for me, it's not guaranteed to work for you out of the box, so be careful.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralWindows Logon Dialog Pin
Anthony988716-Jul-04 5:11
Anthony988716-Jul-04 5:11 
GeneralRe: Windows Logon Dialog Pin
David Crow16-Jul-04 5:21
David Crow16-Jul-04 5:21 
GeneralRe: Windows Logon Dialog Pin
Antony M Kancidrowski16-Jul-04 5:47
Antony M Kancidrowski16-Jul-04 5:47 
Generalsingle instance SDI Pin
vanne16-Jul-04 4:41
vanne16-Jul-04 4:41 
GeneralRe: single instance SDI Pin
Antti Keskinen16-Jul-04 8:39
Antti Keskinen16-Jul-04 8:39 
GeneralMemory Process Pin
VietDelphi16-Jul-04 4:30
VietDelphi16-Jul-04 4:30 
GeneralRe: Memory Process Pin
David Crow16-Jul-04 4:52
David Crow16-Jul-04 4:52 
GeneralRe: Memory Process Pin
Maximilien16-Jul-04 4:57
Maximilien16-Jul-04 4:57 
GeneralRe: Memory Process Pin
VietDelphi16-Jul-04 5:06
VietDelphi16-Jul-04 5:06 
GeneralRe: Memory Process Pin
David Crow16-Jul-04 5:16
David Crow16-Jul-04 5:16 
GeneralRe: Memory Process Pin
bikram singh16-Jul-04 12:01
bikram singh16-Jul-04 12:01 
QuestionMFC with Multiple Dialogs?? Pin
Kunal Shetye16-Jul-04 4:00
Kunal Shetye16-Jul-04 4:00 
AnswerRe: MFC with Multiple Dialogs?? Pin
David Crow16-Jul-04 4:49
David Crow16-Jul-04 4:49 
AnswerRe: MFC with Multiple Dialogs?? Pin
Maximilien16-Jul-04 5:06
Maximilien16-Jul-04 5:06 
GeneralRe: how to get access to the outbox folder Pin
David Crow16-Jul-04 4:46
David Crow16-Jul-04 4:46 
Generalwin32 dll linking problem Pin
ns16-Jul-04 3:43
ns16-Jul-04 3:43 
GeneralRe: win32 dll linking problem Pin
Antti Keskinen16-Jul-04 8:44
Antti Keskinen16-Jul-04 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.