How to create folder using Outlook Object Model?

D

Dkds.Naidu

Hi folks,

I am developing ATL COM Addin for Microsoft Outlook. Everything
works fine. I mean creating tool bar, getting selected items and moving
mails from one folder to another folder. But How to create one new folder via
Outlook Object Model?

I can create folder using MAPI. I need to create a folder in OnConnection
method.

How?

Thanks in advance.
 
D

Dkds.Naidu

Thank you for giving immediate response.

Can you explain elaborately?

Here I am giving rough code. plz correct me.

STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode
ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom)
{
CComQIPtr <Outlook::_Application> spApp(Application);
CComPtr <Outlook::_Explorer> spExplorer;
BSTR
bstrCurrentFolderName = SysAllocString(L"");
spApp->ActiveExplorer(&spExplorer);
//How do I do? How to create a folder here?

return S_OK;
}
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I know only VB techniques. I can see, though, that your code below refers to no folders at all. If you want to create a folder under the one that's currently visible, then the parent folder would be ActiveExplorer.CurrentFolder and you would use the Add method on its Folders collection.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

Dkds.Naidu

thank you.

How to permanently delete the mails from outlook through programmatically?
--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
 
S

Sue Mosher [MVP-Outlook]

Either move them to the Deleted Items folder and then delete them from that folder or use CDO 1.21, instead of the Outlook object model, to delete them.
 
D

Dkds.Naidu

Yes. You are correct. we can folder via folders->add(desired folder); from
NameSpace(session).

I did.It works fine.

--
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
 

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