Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

VBA in Outlook 2007

hello experts,

We are trying to add a command button to menus in outlook that will allow users to save emails into folders on their computer.  At first we were simply dragging the messages out into folders and users were happy because it was simple and was not time consuming.  We have since found that this causes problems because emails have the same name when in an email thread so old copies are overwritten.  Users, being users, are dead against renaming files once they have been dragged out because it is too time consuming!!  Would it be possible to safely code something in outlook and run it from a macro button that would, say, export an email in a single click only to prompt for a file location?  And is this the best way to accomplish this?  What we are trying to do (big picture wise) is stop having to print emails and create paper files for correspondance.  Because we already file word documents we want the emails to be in the same place but don't want to pay for a paperless system due to funds.....any suggestions?


1 Solution
"We are trying to add a command button to menus in outlook that will allow users to save emails into folders on their computer"

Why are they trying to save emails to Folders on a Computer?

Is there any reason why the Built in Functionality of Outlook Personal Folders is not being used.

Especailly since, when they are used you can use the Move Button in the Outlook Ribbon which is populated with folder options from the PST.

So basically works exactly like you descibe above, however into a PST, not a Folder Structure on the Users Local PC.
Helen FeddemaCommented:
What you want is possible, but in addition to selecting the folder, you might also need to allow message renaming, since otherwise you may have problems with overwriting.  Here is some sample code for saving the currently open message to a user-selected folder (you may have problems with permission for some folders, though):
Public Sub SaveMessage()
'Created by Helen Feddema 21-Sep-2011
'Last modified by Helen Feddema 21-Sep-2011

On Error GoTo ErrorHandler

   Dim ins As Outlook.Inspector
   Dim msg As Outlook.MailItem
   Dim itm As Object
   Dim strPath As String
   Dim fd As Office.FileDialog
   Dim appWord As New Word.Application
   'Create a FileDialog object as a Folder Picker dialog box
   '(have to use Word because the Outlook Application object
   'lacks a FileDialog property)
   Set fd = appWord.FileDialog(msoFileDialogFolderPicker)
   With fd
      .Title = "Browse for folder where message should be saved"
      .ButtonName = "Select"
      .InitialView = msoFileDialogViewDetails
      If .Show = -1 Then
         strPath = CStr(fd.SelectedItems.Item(1))
         Debug.Print "User pressed Cancel"
      End If
   End With
   Set ins = Application.ActiveInspector
   Set itm = ins.CurrentItem
   If itm.Class = olMail Then
      Set msg = ins.CurrentItem
      msg.SaveAs Path:=strPath, Type:=olMSG
      msg.Close (olDiscard)
   End If
   Set fd = Nothing
   Set appWord = Nothing
   Exit Sub

   MsgBox "Error No: " & Err.Number _
      & " in SaveMessage procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

computer_says_noAuthor Commented:
thanks for the responses....

apache08 - it's simply because the system is to replace a physical folder full of printed emails and documents and we want to keep the process the same, so we figured to drag emails out into the folder where documents are already stored would be the easiest?  I would really like to use something more robust (emails in folders makes me uncomfortable) but this means spending on a paperless office type system which we cannot afford at the moment

helen - looks like it will do exactly as I wanted...

It's a tricky one, not sure of the best way forwards really, either way there will be an intervention to name and place the file, there is no way to fully automate because email subjects could have been stipulated by the email sender and will therefore not conform to the structure we need. Headache!!


This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now