1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| sub read_eml()
Dim MyDocFile, MyMsg, MsgId, MsgDate, MsgSubject, FileName, intFile, strFile, strIn As String
Dim MyObj As Object, MySource As Object, file As Variant
'-------------------------------------------------
'Boucle sur chaque message du répertoire courant
'-------------------------------------------------
file = Dir(CurrentProject.Path & "\testfile\")
While (file <> "")
MyDocFile = CurrentProject.Path & "\testfile\"
'--------------------------------------------------
'Open the eml file as a text file
'Loop on lines, read Message ID, Date and Subject
'--------------------------------------------------
intFile = FreeFile()
strFile = MyDocFile
Open strFile For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strIn
If Left(strIn, 11) = "Message-ID:" Then
MsgId = Mid(strIn, 13)
MsgBox ("MsgId = " & MsgId)
End If
If Left(strIn, 5) = "Date:" Then
MsgDate = Mid(strIn, 7)
MsgBox ("MsgDate = " & MsgDate)
End If
If Left(strIn, 8) = "Subject:" Then
MsgSubject = Mid(strIn, 10)
MsgBox ("MsgSubject = " & MsgSubject)
End If
Loop
Close #intFile
file = Dir
Wend
End Sub |
Partager