Solved

VBA in Outlook 2007

Posted on 2011-09-20
5
367 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now