You don't have to put that code in the ThisOutlookSession. That's for special things you can do that have to be initialized when outlook starts. You want to save a message when you decide to do it. Put all the stuff i gave in one module and with your message open and active you use alt+F8 and run the macro (or put a button on the ribbon to call that macro). Just copy and past all this coding in one module. The macro to execute is SaveAsTXT. I hope it works out for you. Beware that there may only be one option explicit at the top. you can add Option Private Module beneath it so they can't see the macronames. If you use Alt+F8 and type in SaveAsTXT is will work if a mail is active (I hope).
[VBA]Option Explicit
Public myPath As Variant
Sub SaveAsTXT()
Dim myOlApp as object
Dim myItem As Outlook.Inspector
Dim objItem As Object
'not sure who wrote this but you are already in outlook
'and you have to declare myOlApp if you use it
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the item?"
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
'changed the "c:" with mypath. See if mypath has an ending \
'otherwise use application.pathseparator to get \
myPath = BrowseForFolder("\\")
If myPath = False Then
MsgBox "No directory chosen !", vbExclamation
Else
objItem.SaveAs myPath & strname & ".msg", olMSG
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub
Function BrowseForFolder(Optional OpenAt As Variant) As Variant
'Function purpose: To Browser for a user selected folder.
'If the "OpenAt" path is provided, open the browser at that directory
'NOTE: If invalid, it will open at the Desktop level
Dim ShellApp As Object
'Create a file browser window at the default folder
Set ShellApp = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
'Set the folder to that selected. (On error in case cancelled)
On Error Resume Next
BrowseForFolder = ShellApp.self.Path
On Error Goto 0
'Destroy the Shell Application
Set ShellApp = Nothing
'Check for invalid or non-entries and send to the Invalid error
'handler if found
'Valid selections can begin L: (where L is a letter) or
'\\ (as in \\servername\sharename. All others are invalid
Select Case Mid(BrowseForFolder, 2, 1)
Case Is = ":"
If Left(BrowseForFolder, 1) = ":" Then Goto Invalid
Case Is = "\"
If Not Left(BrowseForFolder, 1) = "\" Then Goto Invalid
Case Else
Goto Invalid
End Select
Exit Function
Invalid:
'If it was determined that the selection was invalid, set to False
BrowseForFolder = False
End Function[/VBA]Charlize