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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| 'Declaration des variables
Dim Ol As Object
Dim Ns As Object
Dim Dossier As Object
Dim i As Object
Dim mybody() As String
Dim cpt As Integer
Dim p As MailDate
Dim mailnontrie() As MailDate
cpt = 0
'//////////////////////////////////////////////////////////////////////////
'instance de l'objet mail
Set Ol = CreateObject("Outlook.Application", "localhost")
Set Ns = Ol.GetNamespace("MAPI")
Set Dossier = Ns.GetDefaultFolder(olFolderInbox)
'//////////////////////////////////////////////////////////////////////////
'extraction des donnees
For Each i In Dossier.Items
'c'est un mail
If TypeOf i Is Outlook.MailItem Then
'c'est le bon mail
If i.UnRead = True And i.Subject = "test" Then
'remplissage du champ mail du tableau non trié
p.mail = i
'////////////////// remplissage du champ mydate du tableau non trié /////////////////////////////////
mybody = Split(p.mail.Body, vbCrLf)
For compt = 0 To UBound(mybody)
'si c'est la ligne "Date"
If InStr(1, UCase(mybody(compt)), UCase("Sur la journée du")) > 0 Then
'recuperation info
p.mydate = Mid(mybody(compt), InStr(1, mybody(compt), "/") - 2, 10)
End If
Next
'////////////////////////////////////////////////////////////////////////////////////////////////////
ReDim mailnontrie(cpt)
mailnontrie(cpt) = p
cpt = cpt + 1
End If
End If
Next |
Partager