Sub CSchene()
Const ForAppending = 8
Dim olkMsg As Outlook.MailItem, strIncidentNumber As String, strStatus As String, varLine As Variant, _
arrLine As Variant, objFSO As Object, objFile As Object
Set objFSO = CreateObject("Scripting.FileSystemobject")
'On the next line change the file name and path.'
Set objFile = objFSO.OpenTextFile("C:\eeTesting\CShene.txt", ForAppending, True)
For Each olkMsg In Application.ActiveExplorer.Selection
For Each varLine In Split(olkMsg.Body, vbCrLf)
arrLine = Split(varLine, ":")
If UBound(arrLine) > 0 Then
Select Case arrLine(0)
Case "Incident Number"
strIncidentNumber = arrLine(1)
Case "Status"
strStatus = arrLine(1)
Exit For
End Select
End If
Next
objFile.WriteLine GetPrintable(strIncidentNumber) & "," & GetPrintable(strStatus)
Next
objFile.Close
Set objFSO = Nothing
Set objFile = Nothing
Set olkMsg = Nothing
msgbox "Done"
End Sub
|