Solved

auto click 'yes' option in VC

Posted on 2009-04-13
3
486 Views
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 

	{

	public:

		OleInitClass()

		{

			OleInitialize(NULL);

		}

		~OleInitClass()

		{

			OleUninitialize();

		}

	};

	// 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("Defaultmail@Gmail.com");

		olMail.SetTo(strEmailId);

		CString strSubject("DEF: 12345");

		olMail.SetSubject(strSubject);

		CString  strBody = _T("Test Mail");

		olMail.SetBody(strBody);

	// Send the message

		olMail.Send();
 

		Res = ::SendMessage(hWnd, uYes, 0, 0);

}

Open in new window

0
Comment
Question by:Harishsona
3 Comments
 

Accepted Solution

by:
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.
0
 
LVL 4

Expert Comment

by:StefanKittel
ID: 24133048
Hello,

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);

Stefan
0
 
LVL 19

Expert Comment

by:alb66
ID: 24157567
You should consider to send the e-mail via SMTP.
Give a look at http://www.codeproject.com/KB/IP/csmtpconn.aspx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 69
Turn a spreadsheet into a vba executable. 2 79
Shell script to login to remote m/c and execute commands 10 78
tripleUp challenge 7 74
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now