How can I create an archive od outlook msgs saved as rtf files (outside of outlook)

  • Thread starter Thread starter Maxx
  • Start date Start date
M

Maxx

How can I create an archive that contains each outlook mshg from the inbox
saved as an rtf file in a folder such as "C:\Messages"?

I'm using Outlook 2003.
 
Set App = CreateObject("Outlook.Application")
Set NS = App.Logon
set Inbox = NS.GetDefaulFolder(6) 'olFolderInbox
for each Msg in Inbox.Items
FileNname = "C:\Messages\" & Msg.Subject
'todo: make sure there are no invalid characters in FileName, such as ":",
"*", etc
Msg.SaveAs FileName, 1 'olRtf
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
I don't understand what NS means?



Dmitry Streblechenko said:
Set App = CreateObject("Outlook.Application")
Set NS = App.Logon
set Inbox = NS.GetDefaulFolder(6) 'olFolderInbox
for each Msg in Inbox.Items
FileNname = "C:\Messages\" & Msg.Subject
'todo: make sure there are no invalid characters in FileName, such as
":", "*", etc
Msg.SaveAs FileName, 1 'olRtf
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Oh, I just realised NS = namespace.

I just want to run a vba routyine from inside outlook 2003 (or excel or
word). I don't have visual studio or anything.

Max
 
In that case, in your VBA macro, replace Dmitry's first two statements with this one:

Set NS = Application.Session
 
Ah, sorry, replace the line

Set NS = App.Logon

with

Set NS = \App.GetNamespace("MAPI")
NS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top