Save e-mail to .msg file

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

Thanks for taking the time to read my question.

I'd like to make a button on my tool bar in Outlook 2007 that will
automatically save the selected e-mail to a predetermined folder. This is
the code I have so far for my macro, but it doesn't work. I get the error
Run-time error '91':
Object variable or With block variable not set

code:
Public Sub ExportSAR()
Dim TheEmail As MailItem
Dim NewFileName As String

NewFileName = InputBox("Enter the SaveAs name", "Save E-mail As", "SAR -
Change - ")

If NewFileName <> "" Then
TheEmail.SaveAs "A:\2009\200907\" & NewFileName, olMSG
Else
MsgBox "No file name was entered. Operation aborted.", 64, "Cancel
Operation"
Exit Sub
End If

End Sub

I can't figure out what I need to fix to make this work. Any help would be
great.

Thanks,

Brad
 
Your code needs a statement to instantiate the TheEmail variable. If you
want the item selected in the current folder view, that would be
Application.ActiveExplorer.Selection(1).
 
Thanks Sue,

I was just lookin at that in the Outlook Developer Reverence - Application
Object Model Map.

I'll try adding this to my code and see what I get.

Brad
 
Back
Top