Zombie49,
Dans un p1er temps, je te propose le squelette de code suivant :
Sub ScanSMS_Mainprocess()
Dim oOL As Outlook.Application
Dim olNS As Outlook.Namespace
Dim oMail As Outlook.MailItem
Dim sSubject As String
Dim sFrom As String
Dim sBody As String
Dim dDate As Date
Set oOL = GetObject(, "Outlook.Application")
Set olNS = oOL.GetNamespace("MAPI")
For Each oMail In olNS.GetDefaultFolder(olFolderInbox).Items
With oMail
If .UnRead Then
sSubject = .Subject
sFrom = .Sender.Name
dDate = .ReceivedTime
sBody = .Body
'
'Ajouter ici du code pour renseigner la feuille EXCEL avec les données récupérées
'
.UnRead = False
End If
End With
Next
Set oMail = Nothing
End Sub
Il faudra que tu références "Microsoft Outlook 16.0 Object Library" (dans IDE VBA : Outils/Références...)
Pour que ça fonctionne, tu dois t'assurer qu'une session OUTLOOK est en exécution. Pour ce faire une petite fonction :
Public Function IsOUTLOOK_OK() As Boolean
Dim oOUTLOOK As Object
IsOUTLOOK_OK = True
On Error Resume Next
Set oOUTLOOK = GetObject(, "Outlook.Application")
On Error GoTo 0
If oOUTLOOK Is Nothing Then
MsgBox "OUTLOOK n'est pas en exécution!", vbCritical, "CONTROLE OUTLOOK ACTIF"
IsOUTLOOK_OK = False
End If
Set oOUTLOOK = Nothing
End Function