How do I get the currently selected mail

  • Thread starter Thread starter B
  • Start date Start date
B

B

I have written a COM addin to add a command bar along
with a menu item to MS Outlook. On clicking this menu item I am able to

identify the currently selected folder.


My approach is as follows:


void __stdcall CAddin::OnClickButton(/*IDispa­tch*/
Office::_CommandBarButton *Ctrl,VARIANT_BOOL * CancelDefault)
{


Outlook::MAPIFolder * m_pFolder;
CComQIPtr<Office::_CommandBarB­utton,&__uuidof(Office::_Comma­ndBarButton)>

pCommandBarButton(Ctrl);


BSTR fullFolderPath;


CComQIPtr <Outlook::_Application> spApp(pApplication);
CComPtr<Outlook::_Explorer> spExplorer;


spApp->ActiveExplorer(&spExplo­rer);
spExplorer->get_CurrentFolder(­& m_pFolder);
m_pFolder->get_FullFolderPath(­& fullFolderPath);



}


What I intend to do is to retrieve certain properties of a mail that is

currently selected by the user when he clicks MyMenuButton.

Plz suggest me an approach as to how exactly I can get to know the
currently selected mail. Code snippets would be of great help.
 
The Selection collection of the ActiveExplorer is what you want. You can
iterate that collection to get its contents and you can check its Count
property to see how many items are selected.




I have written a COM addin to add a command bar along
with a menu item to MS Outlook. On clicking this menu item I am able to

identify the currently selected folder.


My approach is as follows:


void __stdcall CAddin::OnClickButton(/*IDispa­tch*/
Office::_CommandBarButton *Ctrl,VARIANT_BOOL * CancelDefault)
{


Outlook::MAPIFolder * m_pFolder;
CComQIPtr<Office::_CommandBarB­utton,&__uuidof(Office::_Comma­ndBarButton)>

pCommandBarButton(Ctrl);


BSTR fullFolderPath;


CComQIPtr <Outlook::_Application> spApp(pApplication);
CComPtr<Outlook::_Explorer> spExplorer;


spApp->ActiveExplorer(&spExplo­rer);
spExplorer->get_CurrentFolder(­& m_pFolder);
m_pFolder->get_FullFolderPath(­& fullFolderPath);



}


What I intend to do is to retrieve certain properties of a mail that is

currently selected by the user when he clicks MyMenuButton.

Plz suggest me an approach as to how exactly I can get to know the
currently selected mail. Code snippets would be of great help.
 
Back
Top