SaveAs Method Example

SaveAs Method Example

This Visual Basic for Applications example uses the SaveAs method to save the currently open item as a text file in the My Documents folder, using the subject as the file name.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.SaveAs "C:\My Documents\" & myItem.Subject & ".txt", olTXT

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.ActiveInspector.CurrentItem
myItem.SaveAs "C:\My Documents\" & myItem.Subject & ".txt", 0