Solved

How do I create a new Outlook folder from Excel ?

Posted on 2013-11-09
11
239 Views
Last Modified: 2013-11-10
Hi,

I would like to create a new named Outlook folder from within my Excel 2010 application.

The folder name will be input by the user and appended to the following Outlook folder structure :

Personal Folders/Orders/

I'm not sure where to begin with this.

Thanks
Toco
0
Comment
Question by:Tocogroup
  • 6
  • 4
11 Comments
 
LVL 23

Expert Comment

by:Michael74
Comment Utility
Try this, it is based on an example here
http://social.msdn.microsoft.com/Forums/en-US/768649d6-be9a-4543-ba0a-9c0a31f1aa7b/working-with-outlook-public-folders-from-excel

Dim OL As Outlook.Application
Dim NS As NameSpace
Dim APFs As MAPIFolder      'All Public Folders
Dim MYPF1 As MAPIFolder  'My Pub Folder 1
Dim NewItem As PostItem
  
Set OL = CreateObject("Outlook.Application")
Set NS = OL.GetNamespace("MAPI")
Set APFs = NS.Folders("Public Folders").Folders("All Public Folders")

  ' Enter a valid Public Folder Name below
Set MYPF1 = APFs.Folders("Orders")

MYPF1.folders.Add("Test")

Open in new window

0
 

Author Comment

by:Tocogroup
Comment Utility
I'm getting a 'User-defined type' error at run-time. Please see attached screenshot.
0
 

Author Comment

by:Tocogroup
Comment Utility
Let's try uploading the file this time
Create-OL-folder-screenshot.jpg
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
Look at sample
You will need some libraries in your project (Tools-References in VBA Editor):
referencesAddFolder.xlsm
0
 

Author Comment

by:Tocogroup
Comment Utility
Ok. I got a little further down the line with a different runtime error (see attached screenshot) on the Set APFs line.
Create-OL-folder-screenshot-erro.jpg
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 39

Expert Comment

by:als315
Comment Utility
Tocogroup: have you tested my sample?
0
 

Author Comment

by:Tocogroup
Comment Utility
Hi als315.

Yes I have tested your sample. Hence the screenshot and post above of the second runtime error.
Just to confirm, I checked the libraries as per your screenshot.
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
Screenshot above is with code from Michael74.
Do you like to add folder to public folders or to personal folders?
0
 

Author Comment

by:Tocogroup
Comment Utility
Personal folders.
I tried replacing 'Public folders' with 'Personal folders' but had the same runtime error.
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
I should ask again: have you tested my sample? If there are any errors, can you show them?
0
 

Author Closing Comment

by:Tocogroup
Comment Utility
Apologies als315. My error !

I've copied your sample into my application and it works absolutely fine.

Many thanks for your patience
Toco
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now