Click here to Skip to main content
15,892,674 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CString to LPCSTR. Pin
toxcct23-Jan-07 2:21
toxcct23-Jan-07 2:21 
GeneralRe: CString to LPCSTR. Pin
uday kiran janaswamy23-Jan-07 3:05
uday kiran janaswamy23-Jan-07 3:05 
Questionmain() Pin
Anilkumar K V23-Jan-07 1:18
Anilkumar K V23-Jan-07 1:18 
AnswerRe: main() Pin
toxcct23-Jan-07 2:18
toxcct23-Jan-07 2:18 
GeneralRe: main() Pin
David Crow23-Jan-07 3:15
David Crow23-Jan-07 3:15 
GeneralRe: main() Pin
toxcct23-Jan-07 3:16
toxcct23-Jan-07 3:16 
AnswerRe: main() Pin
Waldermort23-Jan-07 2:23
Waldermort23-Jan-07 2:23 
QuestionMicrosoft Outlook: "A Program is trying to send email.." [modified] Pin
Abris23-Jan-07 0:48
Abris23-Jan-07 0:48 
I have a program that automatically shall send alot of emails through Outlook, and I want to get rid of the warning "A Program is trying to send email..." that pops up everytime you try to send an email.
First of all.. I know there are programs available that I could try and use like "ClickYes" and "Quick-Merge".

However I do not want to rely on another software to do the stuff for me. What I want to do is to add a hook that sees when the security warning dlg comes up and then closes it automatically by pressing the yes buttton before the five seconds are up.

I have tried the following and it almost works:

BOOL CALLBACK EnumAppearanceChildProc2(HWND hwnd, LPARAM lParam)
{
	TCHAR buff[512];
	GetWindowText(hwnd,buff,512); 
    if(_tcscmp(buff,_T("Yes")) == 0)
    { 
        *reinterpret_cast<HWND*>(lParam) = hwnd;
        return FALSE;
    }
    return TRUE;
}
HWND GetYesButton(HWND hWndParent)
{
	HWND hWnd = NULL;

	EnumChildWindows(hWndParent, EnumAppearanceChildProc2, 
		(LPARAM)&hWnd);
	return hWnd;
}

LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if(nCode == HCBT_ACTIVATE)
	{
		HWND hWnd = (HWND) wParam;
		TCHAR buff[512];
		GetWindowText(hWnd,buff,512);
		if(_tcscmp(buff,_T("Microsoft Office Outlook")) == 0)
		{	
			SetWindowText(hWnd,"Correct Window");
			HWND YesButton=GetYesButton(hWnd);
			SetWindowText(YesButton,"Correct Button");
			EnableWindow(YesButton,true);
			Sleep(100);
			PostMessage(YesButton,BM_CLICK,0,0);  // Does not work!!
			g_hWndEffects = hWnd;		
			UnhookWindowsHookEx(g_hook);						
		}
	}
}

In the main program I then call:
g_hook = SetWindowsHookEx(WH_CBT, CBTProc, g_hModule, 0);

This code finds the window and automatically activates the yes button in the security dialogue, but the press command that I send has no effect. If I click the button myself with the mouse the yes button has effect and it can be pressed before the five seconds is up.

Can anybody explain why the press in my code has no effect?

AngryOutlookUser



-- modified at 7:15 Tuesday 23rd January, 2007
AnswerRe: Microsoft Outlook: &quot;A Program is trying to send email..&quot; Pin
toxcct23-Jan-07 0:51
toxcct23-Jan-07 0:51 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
Abris23-Jan-07 0:59
Abris23-Jan-07 0:59 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
toxcct23-Jan-07 1:04
toxcct23-Jan-07 1:04 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
Abris23-Jan-07 1:10
Abris23-Jan-07 1:10 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
toxcct23-Jan-07 2:16
toxcct23-Jan-07 2:16 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
Abris23-Jan-07 5:04
Abris23-Jan-07 5:04 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
David Crow23-Jan-07 3:17
David Crow23-Jan-07 3:17 
GeneralRe: Microsoft Outlook: &amp;amp;amp;quot;A Program is trying to send email..&amp;amp;amp;quot; [modified] Pin
Abris23-Jan-07 5:02
Abris23-Jan-07 5:02 
AnswerRe: Microsoft Outlook: &amp;quot;A Program is trying to send email..&amp;quot; Pin
James R. Twine23-Jan-07 2:59
James R. Twine23-Jan-07 2:59 
GeneralRe: Microsoft Outlook: &amp;quot;A Program is trying to send email..&amp;quot; Pin
Abris23-Jan-07 5:01
Abris23-Jan-07 5:01 
GeneralRe: Microsoft Outlook: &amp;quot;A Program is trying to send email..&amp;quot; Pin
James R. Twine23-Jan-07 6:19
James R. Twine23-Jan-07 6:19 
GeneralRe: Microsoft Outlook: &amp;quot;A Program is trying to send email..&amp;quot; Pin
Abris24-Jan-07 19:42
Abris24-Jan-07 19:42 
AnswerRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
Chris Meech23-Jan-07 7:15
Chris Meech23-Jan-07 7:15 
GeneralRe: Microsoft Outlook: &amp;amp;quot;A Program is trying to send email..&amp;amp;quot; Pin
Abris24-Jan-07 19:45
Abris24-Jan-07 19:45 
Questionhow to create the UI like pcAnywhere?[help] [modified] Pin
pollux_zy23-Jan-07 0:43
pollux_zy23-Jan-07 0:43 
AnswerRe: how to create the UI like pcAnywhere?[help] Pin
Mark Salsbery23-Jan-07 8:35
Mark Salsbery23-Jan-07 8:35 
Questionsize of object Pin
Try23-Jan-07 0:20
Try23-Jan-07 0:20 

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.