VBA Script to save emails to my hard disk

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have recently moved jobs, and at my old place we had a button in oulook
running a vba macro to file emails in msg to the servers hard disk.
Unfortunatly I was unable to take he script with me.
On the local HD there were txt files containing the following:-
Year.txt - containing a list of years available ie 00, 05, 06, 07 etc
07.txt - containing all the jobs in that year ie 07001 - job 1.
You clicked on the email to be filled, either in the Inbox or SentMail, then
you click on the button for the macro and the script runs. It asks you for
the job year (listed in year.txt) and then you pick the job (listed in
07.txt) and the the email is filed with a date code on the servers HD in a
suitable directory, ie ..../07/07001/xxx.msg.

Can you help with writing the script to do the above, or if not point me in
the direction of some suitable help. Unfortunatly my knowledge of VBA is
limited, I am more of an end user.

Thanks in advance for all your help

Steve
 
Ok, give this a try. This solution comes in two parts, an Outlook userform
and a small macro that launches it. follow this link
(http://www.mindspring.com/~d_lee/frmSave2Disk.zip) to download the userform.
Download the file, it's a zip file, then follow these instructions to import
it.

1. Unzip the two files in the zip.
2. Open Outlook, or switch to it if it's already open.
3. Open the VB Editor.
4. Click File->Import File, select the .frm file and click Open.

Now, add the macro below by following these instructions.

1. Start Outlook.
2. Click Tools->Macro->Visual Basic Editor.
3. If not already expanded, expand Modules and click on Module1.
4. Copy the code below and paste it into the right-hand pane of the VB
Editor.
5. Edit the form code as needed. I placed comments where things can/need
to be changed.
6. Click the diskette icon on the toolbar to save the changes.
7. Close the VB Editor.
8. Click Tools->Macro->Security.
9. Change the Security Level setting to Medium.
10. Create a button to run the macro. If you need instructions on how to do
that, then let me know and I'll post them.

Select one or more messages from any folder and click the button that runs
the macro. It will display a dialog-box allowing you to choose the year and
a job from that year. Clicking Save will save all the selected messages to a
folder associated with the selected year and job. Clicking Cancel exits
without saving anything. The code behind the form assumes a folder structure
like this:

ROOT_FOLDER
Year1
Job1
Job2
Year2
Job1
Job2
Year3
Job1
Job2

I wrote and tested this on a system with Outlook 2003 and it worked
perfectly. The code could be improved on by adding checks to see if the
necessary folders exist and optionally creating them if they don't, fixing
the message subject to remove illegal characters before saving, etc.

Sub SaveMessageToDisk()
Dim objForm As New frmSave2Disk
objForm.Show
Set objForm = Nothing
End Sub
 
Please, help me

I tried this and it worked great, but when there was an attachment it does´t work
 
Back
Top