N
NakedJ
New to coding and need to write script for saving Outlook 2002 (sp3) e-
mail as seperate HTML Files. I feel like I am pretty close, but keep
getting a "Runtime Error 91". What am I missing?
Sub GetFolderContents()
Dim objOutlook As New Outlook.Application
Dim MyOrt As String
Dim objNameSpace As NameSpace
Dim objFolder As MAPIFolder
Dim objMail As Object
Dim i As Integer
'Ask for destination folder
MyOrt = InputBox("Destination", "Save Attachments", "C:\Documents
and Settings\jaflint\My Documents\e-mail")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
'Access the Inbox
For i = 1 To objFolder.Items.Count 'Loop through
all
strname = objMail.Subject
objMail.Subject = "Subject of mail message" 'Subject
line of
'message
objMail.Body = "Body of mail message" 'Body of
mail message
objMail.Saveas "MyOrt" & "strname & .HTML",
olHTML 'Save the message
Next
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Set objMail = Nothing
End Sub
Thanks,
Jason
mail as seperate HTML Files. I feel like I am pretty close, but keep
getting a "Runtime Error 91". What am I missing?
Sub GetFolderContents()
Dim objOutlook As New Outlook.Application
Dim MyOrt As String
Dim objNameSpace As NameSpace
Dim objFolder As MAPIFolder
Dim objMail As Object
Dim i As Integer
'Ask for destination folder
MyOrt = InputBox("Destination", "Save Attachments", "C:\Documents
and Settings\jaflint\My Documents\e-mail")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
'Access the Inbox
For i = 1 To objFolder.Items.Count 'Loop through
all
strname = objMail.Subject
objMail.Subject = "Subject of mail message" 'Subject
line of
'message
objMail.Body = "Body of mail message" 'Body of
mail message
objMail.Saveas "MyOrt" & "strname & .HTML",
olHTML 'Save the message
Next
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Set objMail = Nothing
End Sub
Thanks,
Jason