Sub CShene()
Dim olkMsg As Outlook.MailItem, strIncidentNumber As String, strStatus As String, varLine As Variant, _
arrLine As Variant, objFSO As Object, objFile As Object
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set olkMsg = Application.ActiveExplorer.Selection(1)
Case "Inspector"
Set olkMsg = Application.ActiveInspector.CurrentItem
End Select
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
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)
objFile.WriteLine GetPrintable(strIncidentNumber) & "," & GetPrintable(strStatus)
objFile.Close
Set objFSO = Nothing
Set objFile = Nothing
End Sub
Function GetPrintable(strValue As String) As String
Dim intCount As Integer, strTemp As String
For intCount = 1 To Len(strValue)
strTemp = Mid(strValue, intCount, 1)
Select Case Asc(strTemp)
Case 32 To 126
GetPrintable = GetPrintable & strTemp
End Select
Next
GetPrintable = Trim(GetPrintable)
End Function
|