Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. An Outlook plug-in issue

An Outlook plug-in issue

Scheduled Pinned Locked Moved COM
helpc++htmlquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dorutzu
    wrote on last edited by
    #1

    Hi, I'm witting an Outlook plugin in VC++, using ATL. When a button in outlook is pressed, my plug-in will create a new mail, or reply to the selected one, or forward it. Now, the problem is that after generating this new window(for new mail, reply or fwd), when I close Outlook, another instance of Outlook remains somewhere running (I see it in Task Manager, and I have to close it form there). Any ideea what do wrong? Here is part of my code from the reply command: for(int i=1; i<=lItemCount; i++) { CComPtr spDisp; CComVariant vt(i); //get selected item number i hr = spSelection->Item(vt, &spDisp); if(FAILED(hr)) return; CComQIPtr< Outlook::_MailItem > spMailItem(spDisp); CComPtr spMailItem2; if(FAILED(hr)) return; if(spMailItem!=NULL) { spMailItem->Reply(&spMailItem2); BSTR subj; spMailItem->get_Subject(&subj); CString str = "Re:"; str += W2T(subj); spMailItem2->put_Subject(T2W(str)); BSTR htmlBody; spMailItem->get_HTMLBody(&htmlBody); str = ReadHTMLIntoString((CString)W2T(bstrMSname)); //insert the Reply .html str += "

    Original text:

    "; //something between our text and the original text str += W2T(htmlBody); htmlBody = T2W(str); spMailItem2->put_HTMLBody(htmlBody); spMailItem2->Display(); } spMailItem2.Detach(); spMailItem.Detach(); spDisp.Detach(); } I think something should be done with spMailItem2, but I just don't know what. I would really appreciate any help. Thanks, Doru K

    M 1 Reply Last reply
    0
    • D dorutzu

      Hi, I'm witting an Outlook plugin in VC++, using ATL. When a button in outlook is pressed, my plug-in will create a new mail, or reply to the selected one, or forward it. Now, the problem is that after generating this new window(for new mail, reply or fwd), when I close Outlook, another instance of Outlook remains somewhere running (I see it in Task Manager, and I have to close it form there). Any ideea what do wrong? Here is part of my code from the reply command: for(int i=1; i<=lItemCount; i++) { CComPtr spDisp; CComVariant vt(i); //get selected item number i hr = spSelection->Item(vt, &spDisp); if(FAILED(hr)) return; CComQIPtr< Outlook::_MailItem > spMailItem(spDisp); CComPtr spMailItem2; if(FAILED(hr)) return; if(spMailItem!=NULL) { spMailItem->Reply(&spMailItem2); BSTR subj; spMailItem->get_Subject(&subj); CString str = "Re:"; str += W2T(subj); spMailItem2->put_Subject(T2W(str)); BSTR htmlBody; spMailItem->get_HTMLBody(&htmlBody); str = ReadHTMLIntoString((CString)W2T(bstrMSname)); //insert the Reply .html str += "

      Original text:

      "; //something between our text and the original text str += W2T(htmlBody); htmlBody = T2W(str); spMailItem2->put_HTMLBody(htmlBody); spMailItem2->Display(); } spMailItem2.Detach(); spMailItem.Detach(); spDisp.Detach(); } I think something should be done with spMailItem2, but I just don't know what. I would really appreciate any help. Thanks, Doru K

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      dorutzu wrote: spMailItem2.Detach(); spMailItem.Detach(); spDisp.Detach(); Whoops! I think you were trying to get the smart pointers to clean up, but they'll do that by themselves. The Detach method is a way to get the smart pointer to stop tracking the underlying pointer, but it does not call Release. Either call Release, or don't do anything.

      D 1 Reply Last reply
      0
      • M Mike Dimmick

        dorutzu wrote: spMailItem2.Detach(); spMailItem.Detach(); spDisp.Detach(); Whoops! I think you were trying to get the smart pointers to clean up, but they'll do that by themselves. The Detach method is a way to get the smart pointer to stop tracking the underlying pointer, but it does not call Release. Either call Release, or don't do anything.

        D Offline
        D Offline
        dorutzu
        wrote on last edited by
        #3

        Thanks! This was the problem indeed! I got, eventually, to the answer by my self, but thanks for your help anyway. Unfortunately, I haven't found too much info on the net on this issue, and I used Detach just for the sake of cleaning up :) Thanks again, Doru K

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups