An Outlook plug-in issue
-
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