A summary of my resolution to this. First, I'm not sure how 'unix' got into the subject line. No unix involved in this. My goal was to read incoming emails (from the Outlook client) into SAS. I now have a procedure that writes each email to a text file (which can be read by sas). The strategy is: 1) Configure an Outlook Rule that runs a VBA script against every candidate incoming email. In recent versions of Outlook you need to change a registry value to permit this. [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Security]"EnableUnsafeClientMailRules"=dword:00000001 2) Use a VBA script as per the following code. (You need to enable a reference to Microsoft Scripting Runtime for the FileSystemObject to work). (There is an alternative Savefile method in VBA but this wraps long lines of text). Sub SaveLIS(Item As Outlook.MailItem)
Dim Received As String
Dim Subject As String
Received = Format(Item.ReceivedTime, "yyyy-mm-dd-hh-MM-ss")
Subject = strLegalFileName(Item.Subject)
Dim objFS As Scripting.FileSystemObject
Dim objOutputFile As Scripting.TextStream
Set objFS = New Scripting.FileSystemObject
Set objOutputFile = objFS.CreateTextFile("C:\temp\Returns\" & Subject & " R; " & Received & ".txt", True)
objOutputFile.Write Item.Body
objOutputFile.Close
End Sub
' Utility function to tidy up filename
Function strLegalFileName(strFileNameIn As String) As String
Dim i As Integer
Const strIllegals = "\/|?*<>"":"
strLegalFileName = strFileNameIn
For i = 1 To Len(strIllegals)
strLegalFileName = Replace(strLegalFileName, Mid$(strIllegals, i, 1), "_")
Next i
End Function
... View more