salut,
Dev rapide :
Cela va regarder les mails dans outlook (repertoire Boite de Reception)
et si le mail correspond a cetains critères :
Excemple:
If i.SenderEmailAddress = "alerte@alerte.com" And i.Subject = "Declenchement alerte" Then 'Si expediteur = "jesaispas@vat.com"
Si sujet = Declenchement alerte ET Adresses Emetteur = alerte@alerte.com alors on peuple excel.
A modifier si necessaire.
Pour le reste :
Sub LireMessages()
Dim olapp As New Outlook.Application
Dim NS As Object, Dossier As Object
Dim OlExp As Object
Dim i As Object
Dim mybody() As String
Dim fromsender As String
Set NS = olapp.GetNamespace("MAPI")
Set Dossier = NS.Folders("Dossiers personnels").Folders("Boîte de réception")
b = 2
For Each i In Dossier.Items
If i.SenderEmailAddress = "alerte@alerte.com" And i.Subject = "Declenchement alerte" Then
sujet = i.Subject
mybody = Split(i.Body, vbCrLf)
fromsender = i.SenderEmailAddress
dejafait = True
For compt = 0 To UBound(mybody)
If InStr(1, UCase(mybody(compt)), UCase("ALERTE")) > 0 And dejafait = True Then
alerte = LTrim(Split(mybody(compt), ":")(1))
dejafait = False
End If
If InStr(1, UCase(mybody(compt)), UCase("Point de mesure")) > 0 Then
PointMesure = LTrim(Split(mybody(compt), ":")(1))
End If
If InStr(1, UCase(mybody(compt)), UCase("Situation")) > 0 Then
situation = LTrim(Split(mybody(compt), ":")(1))
End If
If InStr(1, UCase(mybody(compt)), UCase("Seuil")) > 0 Then
seuil = LTrim(Split(mybody(compt), ":")(1))
End If
If InStr(1, UCase(mybody(compt)), UCase("Liste des alertes")) > 0 Then
mydate = Mid(mybody(compt), InStr(1, mybody(compt), "/") - 2, 10)
End If
Next
Cells(b, 1) = fromsender
Cells(b, 2) = sujet
Cells(b, 3) = Format(mydate, "MM/DD/YYYY")
Cells(b, 4) = alerte
Cells(b, 5) = PointMesure
Cells(b, 6) = seuil
Cells(b, 7) = situation
b = b + 1
End If
Next i
End Sub
Damien