Code to save email to hard drive in .rtf format

J

jrmccaleb

I need to save everything in my .pst file to .rtf. Does anyone have a
macro that could do this?

TIA,

Jeff
 
M

Michael Bauer

Hi Jeff,

I don´t know about any tool, that would do that. If the item is in RTF
format already, so just call the SaveAs method. If it is in HTML e.g.,
then you would need to convert the foromat yourself. AFAIK OL can only
convert from HTML into TXT and then into RTF - but then you will lose
all formattings.
 
J

jrmccaleb

I tried unsuccessfully to run that code. I don't know if I did
something wrong, but it just would not respond when I ran it. I changed
my security settings to medium and still nothing. Any thoughts? Still
rather new to VBA...

There are two things that I am trying to accomplish:

1. Convert a rather large .pst file with thousands of emails.

2. Simplify the process of saving current emails. One button would
create the filename and save it to the appropriate folder or user
selected folder.

Thanks
 
M

Michael Bauer

Hi Jeff,

if you´ve read the article then you know there are a lot of samples for
different OL versions etc. I can´t know what you´ve tried so I can´t
know what you´ve maybe done wrong...

All samples handle only one item, e.g. if it comes into your Inbox or if
you´ve selected it, so you´d have to adapt these samples for your needs.

1. You need to loop through all items instead of handling only incoming,
new items.

2. If an item is converted call it´s SaveAs method for saving to your
harddisk.

This is an general sample for a loop through all folders´ items, which
you can adapt, too. At present the LoopItems and HandleMailItem methods
only handle MailItems. You could copy & paste for different object
types.

' <Sample: Loop through the Outlook folders hierarchy for handling _
each folder item>
Public Sub HandleAllItems(oRoot As Outlook.NameSpace)
LoopFolders oRoot.Folders, True
End Sub

Private Sub LoopFolders(oFolders As Outlook.Folders, _
ByVal bRecursive As Boolean _
)
Dim oFld As Outlook.MAPIFolder

' Loop through all folders.
For Each oFld In oFolders
' Loop through folder items
LoopItems oFld.Items

If bRecursive Then
' Call this function again for going _
deeper into the object hierarchy.
LoopFolders oFld.Folders, bRecursive
End If
Next
End Sub

Private Sub LoopItems(oItems As Outlook.Items)
Dim obj As Object

For Each obj In oItems
Select Case True
Case TypeOf obj Is Outlook.MailItem
HandleMailItem obj
Case TypeOf obj Is Outlook.ContactItem
' Another method for handling ContactItems
' etc.
End Select
Next
End Sub

Private Sub HandleMailItem(oItem As Outlook.MailItem)
' Do s.th. with the object.
End Sub
' </Sample>

--
Viele Grüße
Michael Bauer


I tried unsuccessfully to run that code. I don't know if I did
something wrong, but it just would not respond when I ran it. I changed
my security settings to medium and still nothing. Any thoughts? Still
rather new to VBA...

There are two things that I am trying to accomplish:

1. Convert a rather large .pst file with thousands of emails.

2. Simplify the process of saving current emails. One button would
create the filename and save it to the appropriate folder or user
selected folder.

Thanks
 

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