• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

auto click 'yes' option in VC

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
Harishsona
Asked:
Harishsona
1 Solution
 
DothuCommented:
You may need to create another thread to achieve it. Because the process will block until  the msg windows is closed.
0
 
StefanKittelCommented:
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
 
alb66Commented:
You should consider to send the e-mail via SMTP.
Give a look at http://www.codeproject.com/KB/IP/csmtpconn.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now