Solved

VBA in Outlook 2007

Posted on 2011-09-20
5
370 Views
Last Modified: 2012-05-12
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?

Thanks

computersaysno
0
Comment
Question by:computer_says_no
5 Comments
 
LVL 47

Expert Comment

by:apache09
ID: 36576499
"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.
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 36576746
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))
      Else
         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
   
ErrorHandlerExit:
   Set fd = Nothing
   Set appWord = Nothing
   Exit Sub

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

End Sub

Open in new window

0
 

Author Comment

by:computer_says_no
ID: 36709215
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!!

thanks

computersaysno
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37068436
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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