特定の名前のメールを受信すると差出人の名前をメッセージボックスに表示
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
SaveToCsv EntryIDCollection
End Sub
'
Private Sub SaveToCsv(ByVal EntryIDCollection As String)
Const AUTO_SAVE_TITLE = "受注" ' 自動処理するメールの件名
Dim i As Integer
Dim j As Integer
Dim arrEntryId
Dim myMsg
Dim stmCsv
Set stmCsv = Nothing
arrEntryId = Split(EntryIDCollection, ",")
For i = LBound(arrEntryId) To UBound(arrEntryId)
Set myMsg = Application.Session.GetItemFromID(arrEntryId(i))
If myMsg.Subject = AUTO_SAVE_TITLE Then
MsgBox myMsg.SenderName
Dim strCode
Dim strName
Dim strQuantity
If stmCsv Is Nothing Then
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set stmCsv = objFSO.OpenTextFile(CSV_FILE, 8, True, 0)
End If
stmCsv.WriteLine myMsg.SenderName & j
j = j + 1
End If
Next
If Not stmCsv Is Nothing Then
stmCsv.Close
End If
End Sub