Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / May 2004

Tip: Looking for answers? Try searching our database.

Add new folder to root.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony Yio - 18 May 2004 10:33 GMT
Hello,

   I am trying to add folder to the Personal Folders but it failed. It
could only add folder under my Default Mail , Task sub folder but not
directly under my root folder 'Personal Folder'

Below are my codes

BSTR senderName=NULL;

long lUnreadItemCount=0;

CComPtr<Outlook::MAPIFolder> spMAPIFolder;

CComPtr<Outlook::_Folders> spFolder;

CComPtr<Outlook::_Folders> spSubFolder;

CComPtr<Outlook::_Items> spItems;

CComPtr<Outlook::_NameSpace> spNameSpace;

CComPtr<Outlook::_DRecipientControl> spRecipientCtrl;

BSTR nameSpaceType = T2W("MAPI");

m_spApp->GetNamespace(nameSpaceType,&spNameSpace);

spNameSpace->GetDefaultFolder(olFolderInbox,&spMAPIFolder);

CComPtr<Outlook::_Folders> spTestFolder;

CComPtr<Outlook::MAPIFolder> spAddedMAPIFolder;

spMAPIFolder->get_Folders(&spTestFolder);

spTestFolder->Add(_bstr_t("TEST"), _variant_t((long)olFolderInbox),
&spAddedMAPIFolder); //this will work on add to folder under default mail
folder.

CComPtr<Outlook::MAPIFolder> spAddedSubFolder;

spFolder->Add(_bstr_t("TEST AGAIN"), _variant_t((long)olFolderJournal),
&spAddedSubFolder); //this will NOT work. Any pointers?

thanks in advance.
Dmitry Streblechenko \(MVP\) - 18 May 2004 15:55 GMT
It doesn't look like spFolder is initialized.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Hello,
>
[quoted text clipped - 42 lines]
>
> thanks in advance.
Anthony Yio - 19 May 2004 04:04 GMT
Sorry for the mess, below are the testing codes

  CComPtr<Outlook::_Folders> spFolder;
  CComPtr<Outlook::_NameSpace> spNameSpace;
  CComPtr<Outlook::MAPIFolder> spAddedFolder;

  BSTR nameSpaceType = T2W("MAPI");

   //m_spApp is a CComPtr<Outlook::_Application> that initialize somewhere

  m_spApp->GetNamespace(nameSpaceType,&spNameSpace);
  spNameSpace->get_Folders(&spFolder);

  spFolder->Add(_bstr_t("TESTAGAIN"), _variant_t((long)olFolderInbox),
&spAddedFolder);

   //why is it that the TESTAGAIN folder is not added
   //are there any rules apply by Outlook itself on
   //creating a new folder under root?

thank you.

> It doesn't look like spFolder is initialized.
>
[quoted text clipped - 49 lines]
> >
> > thanks in advance.
Dmitry Streblechenko \(MVP\) - 19 May 2004 06:16 GMT
Namespace.Folders is not a real folder, but rather a collection of all top
level folders from all message stores in the current session.
To add a new PST store to the current profile, use Namespace.AddStore()
passing a fully qualified path to the PST file.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Sorry for the mess, below are the testing codes
>
[quoted text clipped - 72 lines]
> > >
> > > thanks in advance.
Anthony Yio - 19 May 2004 06:59 GMT
thanks for the prompt reply.

> Namespace.Folders is not a real folder, but rather a collection of all top
> level folders from all message stores in the current session.
[quoted text clipped - 85 lines]
> > > >
> > > > thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.