Outlook Quick Search Folder Structure by Name - vba

Is there any easy way to quickly search for the name of a folder in Outlook's inbox folder structure?
I am talking about this:
I have to categorize emails into this folder structure as they arrive but 99% of the time is looking for the right folder...
We are running our own Exchange and I am using Outlook over rdp
http://i.stack.imgur.com/wZDKS.png

The Outlook object model doesn't provide any property of method for that.
You need to develop a VBA macro or add-in to ge the job done. For example, you can iterate over the folders structure to find the required one. The Folders property of the Folder class returns the Folders collection that represents all the folders contained in the specified Folder. So, you may walk down to the tree recursively.

Related

How to detect "This computer only" flag in Outlook folder names in VSTO addin?

Starting from Outlook 2013 and newer, Outlook may sometimes (in case of .OST files) append "(This computer only)" suffix to folder names. In other cases (.PST files) this does not happen. So, depending on particular circumstances a folder name can be "Some folder" or "Some folder (This computer only)" or "Some folder (who knows what else)" for localized versions of Outlook.
Is there any way to get the folder name without this suffix (so that I'd always get, let's say, "Some folder" regardless of whether this suffix is present in the folder name or not? Currently I don't see any property in Outlook.Folder object which would return me that short name.
I can think of a workaround like getting the default Contacts folder name, checking if it ends with "(something)" and then stripping "(something)" off folder names but it does not seem an elegant solution for me.
Another approach could be creating a temp folder and checking if its name is different from the one I provided. If they are different, that difference is the suffix. However, creating/deleting a folder just for that doesn't look elegant either.
In MFCMapi tool, I also can't find "Contacts" anywhere in the MAPI properties of the folder named "Contacts (This computer only)" so it doesn't seem to be just Outlook OOM limitation.
It it true that there is no way to get the folder name without that suffix programmatically and I should rely on my (ugly) workarounds only?
Do not rely on the folder names. Besides having the "(This computer only)" suffix for the IMAP4 stores, the names can be localized.
Always use Namespace.GetDefaultFolder and Store.GetDefaultFolder.

Finding an email in outlook with different folder structures

I've done some searching, and I can't quite find a definitive yes or no answer anywhere.
I'm writing a program that will, when you press a button in Excel, go to outlook, scan it for particular e-mails, then download the attachments in a certain way. Ok, very doable, lots of guides out there how to do it.
What I can't find is if it's doable on a variable folder structure. As in, everyone who's going to use this program has their outlook folders set up in a different way. Is there a way to be able to find the emails I want wherever they're hiding, without creating a unique path per person who might use this program, and without making every person who might use this email set up their inbox in the same way?
The email name will be the same every day, with a date appended, which is how I plan to find the email in the first place.
If the folders you're looking for all have something in common, you might be able to use a For Each loop and a conditional:
For each folder in myFolder.Folders
If folder.Name = "Surprise Party" then
'Run code
End If
Next folder
Looping through a dynamic number of folders to find a specific item is not the best option performance wise. A better approach is to use the AdvancedSearch method. You can specify multiple folders and include subfolders and then iterate through a single collection (.Results).

How to delete Search Folders

Is it possible to delete Search Folders in Outlook using VBA?
I'm trying to figure out, but I don't know how to do it.
My goal is to make a search folder as a temporary storage of my mails and delete it after accessing the emails inside the search folder. I already have the code for creating search folder. But what I want to do is delete the search folder.
I found a code in slipstick.com but my knowledge is not enough to understand the whole process of the program:
http://www.slipstick.com/developer/create-an-outlook-search-folder-using-vba/
Use the Delete method of the Folder class.

Creating folders in Outlook 2010

I have a folder containing many subfolders on my desktop that I need to recreate in outlook 2010. The folders are empty and I have it as a template. There is something like 400 folders so I am trying to avoid manually creating every one of them in outlook.
The issue I have is that these folders aren't being put under my inbox, they are going to be created under a common mailbox accessible by my coworkers. We are using this for archiving purposes. Most of the codes I have found are for creating folders under your inbox.
How would I go about recreating the directory under this public mailbox? I have very little experience in VBA programming. I also have all the folder names in excel if that makes it any easier to accomplish this.
Thanks in advance for any help.
Well, I'd suggest starting from the Getting Started with VBA in Outlook 2010 article in MSDN to learn the basics. From the Outlook object model there is no difference where the folder is located. The Add method of the Folders class creates a new folder in the Folders collection.
You may use the Stores property of the Namespace class which returns a Stores collection object that represents all the Store objects in the current profile. Also the GetSharedDefaultFolder method of the Namespace class returns a Folder object that represents the specified default folder for the specified user.

Outlook VBA loading a saved file from HD

I've found quite a bit on how to automate saving emails and attachments from Outlook to drive locations, but I'm lost on how to access and manipulate those objects that are now saved. So, as an example, I have a folder on my desktop ('C:\Desktop\emails\') with about 1000 emails, and I need to pull the attachments from each of them. The process of extracting attachments in an iterated method is well documented, I'm just stuck on how to actually specify that folder and use it.
Are the MSG files? Use Application.Session.OpenSharedItem to open each MSG file and get back the MailItem object.