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
| Public Sub Application_NewMail()
Dim session As Object
Dim r
Dim Qui As String, strinfos As String
Dim folder As Object
Dim MonMail As Object
Dim i As Integer
Dim condition As Integer, Message As String, Sujet As String
'Instance des Objets
Set session = CreateObject("Redemption.RDOSession")
session.Logon ("Outlook")
Set folder = session.GetDefaultFolder(olFolderInbox) ' 'Dossier boîte de réception
For i = folder.Items.Count To folder.Items.Count
'instancie le mail suivant la valeur de la boucle
Set MonMail = folder.Items(i)
'Récupère les diverses informations du Mail
With MonMail
strinfos = "Expéditeur : " & .SenderName
strinfos = strinfos & vbCr & "Destinataire(s) : " & .To
strinfos = strinfos & vbCr & "Date de réception : " & .ReceivedTime
strinfos = strinfos & vbCr & "Sujet : " & .Subject
strinfos = strinfos & vbCr & "pièce jointe : " & .Attachments.Count
strinfos = strinfos & vbCr & "Message : " & .Body
If .ReplyRecipientNames = "" Then
Qui = .SenderName
Else
Qui = .ReplyRecipientNames '.SenderName
End If
condition = .Importance
Sujet = .Subject
End With
'Affichage du résultat
If condition = 2 Then
Message = " message important. " & " " & Sujet
' r = Shell("C:\Documents and Settings\upath0\Mes documents\parc\gestion PDM\gestion_PDM10" & "\balabolka.exe -nmrq " & """Tu viens de recevoir un mail de " & " " & Qui & Message & "", vbMinimizedNoFocus)
Else
' r = Shell("C:\Documents and Settings\upath0\Mes documents\parc\gestion PDM\gestion_PDM10" & "\balabolka.exe -nmrq " & """Tu viens de recevoir un mail de " & " " & Qui & "", vbMinimizedNoFocus)
End If
Next i
'MsgBox strinfos, vbApplicationModal
'Vide des instances
'Set MonApply = Nothing
Set session = Nothing
Set folder = Nothing
Set MonMail = Nothing
End Sub |
Partager