Hi,

I want to be able to configure Outlook to run a few simple batch files whilst I'm away from my desk (in meeting, email a few commands from a handheld, and PDF sent to my boss whilst I'm still in meeting).

Most of this is working, except I need to approve the saveas/ file write to have access to my "Address book" each time it saves the text from an email. This defeats the object.

I got that problem when I used this format:


[vba]'------------------------------------------------
Public Sub PRS(MyMail As MailItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set aFile = fso.CreateTextFile(strTarget & "C:\PRS\REALLY_PAR.txt", True)
parastring = MyMail.Body

aFile.WriteLine (parastring)
aFile.Close

Set fso = Nothing
Set aFile = Nothing

End Sub

'------------------------------------------------[/vba]



Since then I've been through archieves and found a posting on this website, which flashed up the contents of a email (text only) as a MSGBOX string, I've modded that to the following. This *almost* works, but unfortunately when the email comes in with the code word in subject line, it doesn't auto select, so after the command comes in, it saves the text from the last email I was looking at to the text file. -No Good! -

Here's the modded text macro, any ideas? :




[vba]'------------------------------------------------
Sub GetSelectedMailText()
Set fso = CreateObject("Scripting.FileSystemObject")
Set aFile = fso.CreateTextFile(strTarget & "C:\PRS\PAR.txt", True)
Dim myOlSel As Outlook.Selection
Dim strText As String

'check there's something selected
If Application.ActiveExplorer.Selection.Count = 1 Then
Set myOlSel = Application.ActiveExplorer.Selection
strText = myOlSel.Item(1).Body
'do something with the mail item body text

aFile.WriteLine (strText)
aFile.Close

End If

Set fso = Nothing
Set aFile = Nothing
End Sub

'------------------------------------------------[/vba]



Thanks in advance.

-Andy S