本帖最后由 andyweike 于 2010-03-04 00:11:23 编辑

解决方案 »

  1.   

    最近也在弄outlook 的插件, 楼主能不能给点学习资料?  我不知道如何与outlook对象交互  比如获取其数据文件的路径
      

  2.   

    基本的例子网上有一些,http://www.codeproject.com里有些英文的。
      

  3.   

    另创建了一个atl类
    class ATL_NO_VTABLE CMyInspectorEvent :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CMyInspectorEvent, &CLSID_NULL>,//CLSID_MyInspectorEvent
    public IConnectionPointContainerImpl<CMyInspectorEvent>,
    public CProxy_IMyInspectorEventEvents<CMyInspectorEvent>,
    public IDispatchImpl<IMyInspectorEvent, &IID_IMyInspectorEvent, &LIBID_OutlookAddinLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,

    ,public IDispEventSimpleImpl<1,CMyInspectorEvent,&__uuidof(Office::_CommandBarButtonEvents)>//响应点击按钮事件
    ,public IDispEventSimpleImpl<2,CMyInspectorEvent,&__uuidof(Outlook::ItemEvents)>//响应关闭窗口事件
    ,public IDispEventSimpleImpl<3,CMyInspectorEvent,&__uuidof(Outlook::ApplicationEvents)> //响应发送邮件事件
    {
    }
    在主atl类的NewInspector(IDispatch* pdispInspector)方法中(NewInspector方法响应打开新建邮件页面)
    IDispatchPtr pDisp(pdispInspector);  
    CComQIPtr<_Inspector> spInspector(pDisp);
    CComPtr< IDispatch > spItem;
    CComQIPtr < Office::_CommandBarButton> cmdButton; //得到MailItem
    spInspector->get_CurrentItem(&spItem); 
    CComQIPtr< Outlook::_MailItem> spMailItem(spItem); if(!spMailItem)//新邮件页面
    {
    return;
    } //在新邮件页面中显示“发送提醒”按钮
    CComPtr<_CommandBars> pCmdBars;
    spInspector->get_CommandBars(&pCmdBars); 
    ...
    IDispatch* pEvent = NULL; 
    CMyInspectorEvent::CreateInstance(&pEvent); 
    CMyInspectorEvent* pEvent = (CMyInspectorEvent*)pEvent; pEvent->m_MailItem=spMailItem;
    pEvent->m_RecipientNoticeButton=cmdButton; pEvent->AdviseEvent();// 自定义的函数,绑定CMyInspectorEvent中的那三个事件.        每次点击新建都会进入NewInspector,但新建多个页面后,每个页面的m_RecipientNoticeButton按钮都会触发多次事件。
            怎么样不要绑定多次事件,请指教。