Catching "move to explorer" event from Outlook - vba

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.

Related

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.

Tracking open Outlook 2010 emails

I'm looking for a programmatic way (eg: using VBA) to write the Subject texts of emails which are open, or otherwise export opened emails to a file system folder.
Trap the Application.Inspectors.NewInspector event an read the Inspector.CurrenmtItem.Subject property. Reading pane needs to be handled separately.

Outlook automatic archive on network drive

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.

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.

Outlook MailItem cache issue when saving in vb.net

I have a small WinForms program that allows my users to create email blasts for our clients. The app has two options: one is an HTML editor to design the email (works great) and the second is to import .msg or .oft template.
Once the email is complete it is moved to a shared outlook mailing folder for a nightly macro send job.
Pretty simple stuff!
The problem: Once the template is open in the application outlook seems cache that version. If the user decided to get out make a change in the template Outlook doesn't pick up the update.
Note: If the users clicks on the "Preview" button they received the correct UPDATED version in their inbox. But when they submit the MailItem it picks up the old version.
Dim newItem as Outlook.MailItem = gobjOutlook.CreateItemFromTemplate(fileEmailTemplate.FileName)
The send command works fine newItem.Send()
But when I move it to the shared folder it gets the original version from somewhere.
Dim addFldr As Outlook.MAPIFolder
addFldr = StoreFLDR.Folders.Add(gobjNamespace.CurrentUser.Name & ": " & DateTime.Now.ToString())
newItem.Save()
newItem.Move(addFldr )
I have tried forcing the GC and SaveAs to another location and reload the template, no luck.
I'd suggest starting from releasing underlying COM objects instantly. Use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object.
You may find the How To: Create a new Outlook message based on a template article helpful. Anyway, it would be great to see your full source code related to Outlook.