auto click 'yes' option in VC

Posted on 2009-04-13
Last Modified: 2013-11-20
Hello Experts
Want  to remove the security feature which asks for  "A program is trying to send e-mail on your behalf. Do you want to allow this?....... "etc etc.
I am using Outlook 2003 and VC++ and  i dont want to install 'Click Yes' software

i am trying to get the window handle of message box and post a message , but it is not working
Thanks in Advance.
#include "msoutl.h"
#include <comdef.h>
#include "afxinet.h"
#include "wininet.h"
void somefunc()
class OleInitClass 
	// This global class calls OleInitialize() at
	// application startup, and calls OleUninitialize()
	// at application exit...
	OleInitClass g_OleInitClass;
	// Start Outlook.
	// If it is already running,the same instance is used
	_Application olApp;
	COleException e;
	if(!olApp.CreateDispatch(_T("Outlook.Application"), &e))
                                 CString str;
	            str.Format(_T("CreateDispatch() failed error 0x%08lx"), e.m_sc);
	UINT uYes = RegisterWindowMessage(_T("CLICKYES_SUSPEND_RESUME"));
	 HWND hWnd = FindWindow(_T("#32770"),_T("Microsoft Office Outlook"));
	 long Res = ::SendMessage(hWnd , uYes, 1, 0);
		_MailItem olMail(olApp.CreateItem(0));
		CString strEmailId = _T("");
		CString strSubject("DEF: 12345");
		CString  strBody = _T("Test Mail");
	// Send the message
		Res = ::SendMessage(hWnd, uYes, 0, 0);

Open in new window

Question by:Harishsona
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Dothu earned 500 total points
ID: 24129083
You may need to create another thread to achieve it. Because the process will block until  the msg windows is closed.

Expert Comment

ID: 24133048

the thread needs to find the window (FindWindow(Classname, Windowname)). Use Spyxx to find this out.
Then use ::SendMessage(wnd, WM_COMMAND, ID_OK, 0);

LVL 19

Expert Comment

ID: 24157567
You should consider to send the e-mail via SMTP.
Give a look at

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 76
wordcount challenge 11 163
I could not set window to top 4 62
listing all the respondents to a twitter feed - Java 5 47
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question