我程序实现调用了OutLook来自动发送邮件,但是它却总是先弹出一个提示窗口,内容如下:
A program is tyring to automatically send e-mail on your behalf.
Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No"
请问设置来怎么取消OutLook的这个警告提示?谢谢~我的这个类内容挺多,我就只发它send邮件的函数给大家看看,看可不可以修改:BOOL CMyEmail::Send(ULONG flags)
{
#ifndef SERVICE
CWaitCursor wait;
#endif
int offset = m_text.GetLength(); // Add 1 space per attachment at the end of the body text.
m_text += CString(' ', m_message.nFileCount); // Set each attachment to replace one of the added spaces at the end of the body text.
for (UINT i = 0; i < m_message.nFileCount; i++)
m_message.lpFiles[i].nPosition = offset++; m_message.lpszNoteText = (LPTSTR) (LPCTSTR) m_text; // Set the body text#ifndef SERVICE
// prepare for modal dialog box
AfxGetApp()->EnableModeless(FALSE);
HWND hWndTop;
CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop); // some extra precautions are required to use MAPISendMail as it
// tends to enable the parent window in between dialogs (after
// the login dialog, but before the send note dialog).
pParentWnd->SetCapture();
::SetFocus(NULL);
pParentWnd->m_nFlags |= WF_STAYDISABLED;
#endif#ifdef SERVICE
int nError /*= m_lpfnMAPILogon(0, _T("Rob"), _T("mapi40"), MAPI_NEW_SESSION, 0, &m_sessionHandle)*/;
nError = m_lpfnSendMail(m_sessionHandle, 0x00000040, &m_message, flags, 0);
#else
int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0); /*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
#endif#ifndef SERVICE
// after returning from the MAPISendMail call, the window must
// be re-enabled and focus returned to the frame to undo the workaround
// done before the MAPI call.
::ReleaseCapture();
pParentWnd->m_nFlags &= ~WF_STAYDISABLED; pParentWnd->EnableWindow(TRUE);
::SetActiveWindow(NULL);
pParentWnd->SetActiveWindow();
pParentWnd->SetFocus();
if (hWndTop != NULL)
::EnableWindow(hWndTop, TRUE);
AfxGetApp()->EnableModeless(TRUE);
#endif // Now free malloced recipients
for (i = 0; i < m_message.nRecipCount; i++)
free(m_message.lpRecips[i].lpszName);
// Then free malloced attachments
for (i = 0; i < m_message.nFileCount; i++)
{
free(m_message.lpFiles[i].lpszPathName);
free(m_message.lpFiles[i].lpszFileName);
} if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
{
#ifndef SERVICE
AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
#endif
return FALSE;
} return TRUE;
}
A program is tyring to automatically send e-mail on your behalf.
Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No"
请问设置来怎么取消OutLook的这个警告提示?谢谢~我的这个类内容挺多,我就只发它send邮件的函数给大家看看,看可不可以修改:BOOL CMyEmail::Send(ULONG flags)
{
#ifndef SERVICE
CWaitCursor wait;
#endif
int offset = m_text.GetLength(); // Add 1 space per attachment at the end of the body text.
m_text += CString(' ', m_message.nFileCount); // Set each attachment to replace one of the added spaces at the end of the body text.
for (UINT i = 0; i < m_message.nFileCount; i++)
m_message.lpFiles[i].nPosition = offset++; m_message.lpszNoteText = (LPTSTR) (LPCTSTR) m_text; // Set the body text#ifndef SERVICE
// prepare for modal dialog box
AfxGetApp()->EnableModeless(FALSE);
HWND hWndTop;
CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop); // some extra precautions are required to use MAPISendMail as it
// tends to enable the parent window in between dialogs (after
// the login dialog, but before the send note dialog).
pParentWnd->SetCapture();
::SetFocus(NULL);
pParentWnd->m_nFlags |= WF_STAYDISABLED;
#endif#ifdef SERVICE
int nError /*= m_lpfnMAPILogon(0, _T("Rob"), _T("mapi40"), MAPI_NEW_SESSION, 0, &m_sessionHandle)*/;
nError = m_lpfnSendMail(m_sessionHandle, 0x00000040, &m_message, flags, 0);
#else
int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0); /*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
#endif#ifndef SERVICE
// after returning from the MAPISendMail call, the window must
// be re-enabled and focus returned to the frame to undo the workaround
// done before the MAPI call.
::ReleaseCapture();
pParentWnd->m_nFlags &= ~WF_STAYDISABLED; pParentWnd->EnableWindow(TRUE);
::SetActiveWindow(NULL);
pParentWnd->SetActiveWindow();
pParentWnd->SetFocus();
if (hWndTop != NULL)
::EnableWindow(hWndTop, TRUE);
AfxGetApp()->EnableModeless(TRUE);
#endif // Now free malloced recipients
for (i = 0; i < m_message.nRecipCount; i++)
free(m_message.lpRecips[i].lpszName);
// Then free malloced attachments
for (i = 0; i < m_message.nFileCount; i++)
{
free(m_message.lpFiles[i].lpszPathName);
free(m_message.lpFiles[i].lpszFileName);
} if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
{
#ifndef SERVICE
AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
#endif
return FALSE;
} return TRUE;
}
解决方案 »
- vc连接服务器端的MySQL数据库必须在发起连接的客户机安装MySQL吗?
- MFC初学者,明明已经定义了,怎还显示错误说没定义啊
- directshow如何叠加图片后保存视频
- 跳不出函数循环,我找半天没找到原因(大家帮忙DEBUG)
- 鼠标钩子的生效问题
- 为什么ColeDataTime类型使用会出错 难道微软出BUG了
- 关于滚动条刷新屏幕的问题,高手请进!
- sendmessage?
- 利用多线程 & CAsyncSocket实现文件传输的问题(技术交流)
- 如果令$test=x*x*x;可否用字符串替代函数将x替代成变量$x,如果不可以怎么样才能实现(我的机器里没有装php,试不了)
- 急!VC对话框焦点问题
- 在CBasePane类里面如何设置Outlook栏里图标的排列、大侠们你们来指点下好吗!
UINT uMode // process error mode
);
怎么个用法?
我程序是在这里弹出那个提示窗口的:#else
int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0);
/*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
#endif
int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0);
/*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
#endif进去看看你这个函数如何实现的。应该是系统设置的问题。
// ...
// 不显示警告
excelApp.SetDisplayAlerts(false);这样就关掉 Excel 的警告, 我是调用的 Excel 服务.
2. 第二种方法必须是运行在Outlook内部的Addin或者VBA程序。在这两种情况下,Outlook会传一个Application对象给你,如果你在使用邮件功能的过程中,任何和邮件相关的对象都是通过这个Application对象直接或者间接创建的,就不会有警告,否则就有,因此你不允许自己创建一个
Outlook.Application,并利用这个对象来操作
按照你的需求,要绕过这个安全限制,你可以再制作一个Outlook的插件,当Outlook启动后插件也被启动,此时把发送邮件的任务交给插件来做。
我也碰到这个问题了,我表示我是通过模拟鼠标点击实现的。。反正我的程序是在server机上使用。