How do I get the currently selected mail

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.
 
K

Ken Slovak - [MVP - Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top