Sub TestSupMail()
Dim o As Object, olSpace As Object, olInbox As Object, m As Object, a As Object
Set o = CreateObject("Outlook.Application")
Set olSpace = o.GetNamespace("MAPI")
Set olInbox = olSpace.GetDefaultFolder(6)
On Error GoTo Error_Handler
Dim id
id = "0000000019F189AEEB456A4F996496BF6BFAFF520700CDCB34C52E0B0143B19E1E49226C56BE00000000010C0000CDCB34C52E0B0143B19E1E49226C56BE00026C9998640000"
Set m = olInbox.Items.Find("[EntryID] = " & id & " ") 'EntryID
If Not m Is Nothing Then
m.Delete
Else
MsgBox "Mail non trouvé..."
End If
ExitSupMAil:
o.Quit
Exit Sub
Error_Handler:
MsgBox "MS Excel a généré l'erreur suivante :" & vbCrLf & vbCrLf & _
"Numéro d'erreur : " & Err.Number & vbCrLf & _
"Source d'erreur : SupMail" & vbCrLf & _
"Description de l'erreur : " & Err.Description, vbCritical, "Une erreur s'est produite!"
Resume ExitSupMAil
End Sub