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
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''Lister les mails d'une Mailbox
'''''''''''''''''' ctrListeMail = le nom de la zone de liste à compléter
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Mailbox2(strMailbox As String, ctrListeMail As Control)
'Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim i As Long
Dim rst As DAO.Recordset
'On vide la table
Set rst = CurrentDb.OpenRecordset("T_TMail", dbOpenDynaset)
While Not rst.EOF
rst.Delete
rst.MoveNext
Wend
'on selectionne la mailbox
Set myNamespace = GetNamespace("MAPI")
Set myFolder = myNamespace.Folders(strMailbox)
'on selectionne le dossier outlook
Set myFolder = myFolder.Folders("Boîte de réception")
Dim oMail As MailItem
Dim oItem As Object
For Each oItem In myFolder.Items
If oItem.Class = olMail Then
Set oMail = oItem
'Pour ma part, il s'agissait d'alimenter une table, mais tu peux remplacer par ton traitement.
rst.AddNew
rst("DateReception") = oMail.ReceivedTime
rst("TitreMail") = oMail
rst("Expediteur") = oMail.SenderEmailAddress
rst("Destinataire") = strMailbox
rst("EntryID") = oMail.EntryID
rst.Update
End If
Set oMail = Nothing
Set myNamespace = Nothing
Set myFolder = Nothing
Next oItem
Me.Refresh
End Function |
Partager