Sub Test6() 'test OK
Dim olApp As Outlook.Application
Dim olNs As Outlook.Namespace
Dim olFld As Outlook.MAPIFolder
Dim oAccount As Outlook.Account
Dim objMail As Outlook.MailItem
Dim Test As String, ChoixCompte
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set olFld = olNs.GetDefaultFolder(olFolderInbox)
'mettre le mail du compte concerné
ChoixCompte = InputBox("Saisir le mail du compte concerné", "Choix du Compte Outlook")
Set oAccount = olApp.Session.Accounts(ChoixCompte)
olFld.Items.Sort "Reçu", False
Set objMail = olFld.Items.GetLast ' Outlook 2010
If TypeOf objMail Is MailItem Then
' mettre nom prénom tel que renseigné dans les Contacts Outlook
If objMail.SenderName = "NOM PRENOM" Then
Test = objMail.SenderName & vbCrLf & objMail.SenderEmailAddress & vbCrLf & objMail.Subject
MsgBox Test
'Si utilisation d'EXCHANGE, alors n'affiche pas l'adresse mail mais le "nom" EXCHANGE
End If
End If
Set objMail = Nothing
Set olFld = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub