Outlook automatic archive on network drive - vba

Am I able to use Outlook to automatically link a folder in outlook with a folder on the network drive?
Let's say I want to use VBA to modify a folder called "New York Store" within outlook. I would like to modify the folder, so whenever I put an email into this folder, it will save the email on a destination on the computer such as "X:\Stores\Outlook Archive\New York Store", and when it has done so, it permanent delete the email from Outlook?
Is it possible to modify a folder (by VBA or something else) to save the email(s) within a folder, and when it has done so, delete the emails from Outlook permanently?
Please let me know, if this is possible :)

To answer your question: Yes. It is possible. You'll need to brush up on programmatic folder control and find a way to "watch" the folder for new items.
Is there a reason that there has to be a folder involved? You'd save a few steps with something like a custom button on the Mail Item ribbon to save to file and delete message.
Or, considerably fewer keystrokes:
F12EnterDel
It will work on one or more items, no additional folder required, and after the first time you save an item at your location X:\Stores\Outlook Archive\New York Store it will default to that folder.

Related

Catching "move to explorer" event from Outlook

Recently I have written small tool (vb.net WinForms) for our company that creates structure and archives all Emails that are in x, y Folder in Outlook. This tool then renames and converts these .msg files to .eml files.
Now it would be perfect, if these Emails would automatically convert themself when user places it directly in the destination in Windows-Explorer folder per Drag and Drop. For that I assume I would have to run script/programm whenever Event X (moving Email from Outlook to explorer) occurs.
Has anyone an idea if catching that event would be possible? Or maybe any better ideas? I thought of some scripts that run on server and check for new files (once daily for example), but the first solution is more appearing to me.
You can catch the Items.ItemAdd event on the folder to track and convert new items.
The Outlook object model doesn't provide any events when items are saved to a folder by dragging and dropping items. You can use a file system watcher to track folder changes, see VBA monitor folder for new files for more information.

How to email dropbox app file paths as clickable hyperlinks?

The company uses dropbox instead of local servers. We often send files to colleagues, but each user has a unique path to the file stored in the dropbox desktop app (e.g. C:\Users\username\Dropbox...).
I was thinking about writing a batch script to copy a file path and strip the beginning of the path. I would then need another script to add the user specific prefix to the file path, and then open the folder/file in file explorer.
I believe I found a way to add a batch file into the menu that pops up when you right click a file/folder by editing the registry. I was thinking it would be possible to write an Outlook add-in for the receiving user to prepend their drive/username etc. to the file path and then open the file/file explorer if a path to a folder is sent.
I was hoping to get some input on this approach, or to know if there is an easier way to handle this. I haven't started any of the code yet.
Why don't you just start using the Dropbox add-in for Outlook?
Dropbox has created an add-in that integrates with Microsoft Outlook. By connecting the Dropbox add-in to your Outlook account, you can:
Replace email attachments with a shared link to any file, big or small
Save email attachments that you receive directly to your Dropbox account
Ensure those with access to a file see updates to it (since shared links always point to the latest version of a file, whereas attachments are just a static copy)
Enabling the integration adds a Dropbox icon to the Outlook compose window. When you click this icon a pop-up window appears, allowing you to select from the contents of your Dropbox. A shared link to any selected file or folder will appear in the body of the email.
While this link looks like an attachment, it's, in fact, a shared link. This means no slow-down in sending emails, and no space limitations in your inbox.
Anyway, if you still want to develop an add-in for extracting an attachment's file path you need to start with Walkthrough: Create your first VSTO Add-in for Outlook.
The NewMailEx event of the Application class which is fired once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem and etc. The EntryIDsCollection string contains the Entry ID that corresponds to that item.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance.

Outlook: How to automatically copy all received messages to another folder and mark as Unread

I have tried to find a script or rule which will let me copy all inbound messages to an archive folder and then mark the mail as unread.
Can anyone point me in the right direction, or help with a script please?
I can find plenty that will mark as read, but not as unread.
Thanks in advance, Neil
An outlook MailItem object has a property UnRead which you can toggle as boolean, either True (unread) or False (read).
Returns or sets a Boolean value that is True if the Outlook item has not been opened (read). Read/write.
and welcome to StackOverflow!
To achieve the result that you are looking for, it would be a simple Outlook Rule. Assuming that you are using Outlook 2013, you would just need to go to your Inbox, the select under the Home tab, Rules. Then create a new rule. Start from a blank rule with messages that you receive. Then click next. (Outlook will ask you whether you are sure if you want the rule to run on every email message, click yes) Then chack the box that states, "move a copy to the specified folder". That folder will be your archive. Then, if you would like to, you can choose whether you want a desktop alert for the email. There is no need to select an option of having the email unread, because the email by default is unread when copied to the archive.
I hope this helps.
As workaround you can create rule based on email size (with a size in a specific range). You can put 0 to 999999 and then move a copy to any folder. This should copy all your inbox emails to another folder.

VB Code to Close Open Subfolders in Outlook

Outlook has an habit of opening sub-folders if an email has been sent to it automatically (through rules). There is no way to turn off this feature.
Does anyone have ideas for code that would periodically (say every 30 seconds), automatically collapse all subfolders within, say, the sent items folder?
Thx
The Outlook object model doesn't provide anything for collapsing folders in the navigation pane.
The Starting Outlook with all folders collapsed/expanded states the following:
To keep the mailbox collapsed even when a new message is being delivered, make sure that your Inbox and other folders that receive email (for instance by a rule) have been added to your Favorites list.

Getting reference to Outlook mailbox root in a macro

I'm trying to move items into a specific folder.
I'm able to move the items into a child folder of the inbox using the typical
myNameSpace.GetDefaultFolder(olFolderInbox).Folders("myfolder")
I want to move items into an arbitrary folder. This currently works fine;
myNameSpace.Folders("Mailbox - Main").Folders("myfolder")
But I don't want to hardcode the path. I want to put this macro on a couple of systems and was hoping to avoid writing a unique version for each user.
If you want the root of the default store, use the Inbox parent:
myNameSpace.GetDefaultFolder(olFolderInbox).Parent.Folders("my‌​folder")