我程序实现调用了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;
}

解决方案 »

  1.   

    有一个api,但是不知道是否管用The SetErrorMode function controls whether the system will handle the specified types of serious errors, or whether the process will handle them. UINT SetErrorMode(
      UINT uMode   // process error mode
    );
      

  2.   


    怎么个用法?
    我程序是在这里弹出那个提示窗口的:#else
        int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0); 
    /*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
    #endif
      

  3.   

    C/C++ code#else
        int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0); 
    /*就是这里,outlook会弹出一个窗口问你是否要发送,提示信息看上面*/
    #endif进去看看你这个函数如何实现的。应该是系统设置的问题。
      

  4.   

    我记得我以前操作 Excel 时, _Application  excelApp;
    // ...
    // 不显示警告
    excelApp.SetDisplayAlerts(false);这样就关掉 Excel 的警告, 我是调用的 Excel 服务.
      

  5.   

    一般情况下无解法,这是微软为了防止有人利用Outlook发送垃圾邮件特意加的限制。绕过这个警告的方法只有2个1. 你的程序是在一个Microsoft Exchange Server为邮件服务器的企业环境中,在Exchange的Public Folder和你的客户端分别部署Outlook Security Settings和允许这个setting的注册表,才能绕过(这是Outlook之外使用Outlook 对象模型的唯一办法)
    2. 第二种方法必须是运行在Outlook内部的Addin或者VBA程序。在这两种情况下,Outlook会传一个Application对象给你,如果你在使用邮件功能的过程中,任何和邮件相关的对象都是通过这个Application对象直接或者间接创建的,就不会有警告,否则就有,因此你不允许自己创建一个
    Outlook.Application,并利用这个对象来操作
      

  6.   

    如果你是C++高手且是MAPI高手,用比较原始的mapi,不要用Outlook的如果一定要Outlook,必须保证这是Outlook 2000 SR1之前的版本。新版本禁止不满足我9楼说的两种情况的使用
      

  7.   

    9楼说得对,这是Outlook的安全限制,所有来自不可信代码的访问邮件正文或发送邮件的请求都会收到安全警告。Outlook98及之前的版本没有安全限制,但现在使用的人恐怕没有了。对安全限制得最严格的是Outlook2000版本,不仅弹出安全限制框,有些被用户允许的操作还要进行限时,超过时限的操作不再被允许(即使用户已经确认),不过从2003版本开始已经取消了限时类型的限制,但安全警告还存在。
    按照你的需求,要绕过这个安全限制,你可以再制作一个Outlook的插件,当Outlook启动后插件也被启动,此时把发送邮件的任务交给插件来做。
      

  8.   

    高手多啊。
    我也碰到这个问题了,我表示我是通过模拟鼠标点击实现的。。反正我的程序是在server机上使用。