Save Email message as HTML file on Harddrive

T

TerryM

I've seen quite a few questions asking this on the web, however I have not
seen an answer to it.

I am trying to create an outlook rule that will run on these criterias,
By sender--Easily done in the Outlook rule
By Subject--Easily done in the Outlook rule
run as script--Saves email message as either text or Html to a harddrive.
From there I will do an import into either excel or access to get the
information i need.

So basically what I am trying to find is the script to save the email
message (no attachments) to a hard drive.
 
M

Michael Bauer [MVP - Outlook]

Simply call the item's Save method. There should be an example in the VBA
help file.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 5 Nov 2008 08:28:00 -0800 schrieb TerryM:
 
T

TerryM

I tried the items save as method. It didn't seem to work, that or I had the
code wrong. Mind you I'm pretty new to coding. I've don't a little in Excel
and Access however Outlook is a whole other beast.

What should the code look like anyway. Mind you I'm wanting this to run in
a Rule, so when the email comes in it automatically saves the message body as
an html file to the network drive.
 
T

TerryM

Ok, I figured out what I was doing wrong in regards to the SaveAs Method.
The syntax is different than in Access and Excel. I have been able to save a
file with with a predetermined name to the harddrive. The Message body is
blank however, what code am I missing to select and save the message body
also?

Here is the code listed below:

Sub saveemail(myItem As Outlook.MailItem)
Dim m As MailItem
Set m = CreateItem(olMailItem)
m.SaveAs "c:\temp\New Power Indices.html", olhtml
End Sub
 
M

Michael Bauer [MVP - Outlook]

In your code, m is a new MailItem, which is blank. If you want to save the
e-mail passed by the rule, use myItem:

Sub saveemail(myItem As Outlook.MailItem)
myitem.SaveAs "c:\temp\New Power Indices.html", olhtml
End Sub

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>

Am Tue, 11 Nov 2008 06:38:13 -0800 schrieb TerryM:
 
T

TerryM

That definately took care of the problem. I've noticed that the syntax for
outlook vba is quite a bit different than say Access or Excel. What
resources or books would you suggest for a beginner like me to learn from.

Thanks for all your help.
 
M

Michael Bauer [MVP - Outlook]

Absolute Beginner´s Guide to Microsoft Office Outlook 2003, by Ken Slovak
Microsoft Outlook Programming, by Sue Mosher
Application Development with Outlook 2002, by Randy Byrne


--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 11 Nov 2008 19:22:00 -0800 schrieb TerryM:
 
K

Ken Slovak - [MVP - Outlook]

Michael,

That Absolute Beginners Guide is not a programming book, it's an entry level
user book (like a Dummies book), there's no programming coverage at all in
the book.
 
M

Michael Bauer [MVP - Outlook]

Terry, recommended books are:

Professional Programming Outlook 2007, Wrox Press, by Ken Slovak
Microsoft Outlook Programming, by Sue Mosher

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 11 Nov 2008 19:22:00 -0800 schrieb TerryM:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top