Bonjour Rag,
Merci pour ton retour, grâce à toi j'ai pu finir ma macro et cela marche nickel, la voici:
Sub toto6()
Dim olapp As Outlook.Application
Set olapp = New Outlook.Application
Dim NS As Object, Dossier As Object
Dim OlExp As Object
Dim i As Object
Dim fromsender() As String
Set NS = olapp.GetNamespace("MAPI")
Set Dossier = NS.GetDefaultFolder(olFolderInbox).Folders("CACEIS Etat")
For Each i In Dossier.Items
If i.SenderEmailType <> "EX" And i.UnRead Then
i.UnRead = False
sujet = i.Subject
If InStr(1, UCase(sujet), UCase("Avis d'opérés")) Or InStr(1, UCase(sujet), UCase("Extrait de compte cash")) > 0 Then
If Not i.Attachments.Count = 0 Then
'récupère et renomme la première pièce jointe
Set pceJointe = i.Attachments(1)
pjName = pceJointe.Filename
nombre_aleatoire = Int(1000 * Rnd) + 1
nombre_de_caractere = Len(pjName)
Nv_Pj = Left(pjName, nombre_de_caractere - 4)
Nv_Pj = Nv_Pj & nombre_aleatoire & ".PDF"
pceJointe.SaveAsFile "Votre chemin" & Nv_Pj
Set pceJointe = Nothing
End If
End If
End If
Next i
Call toto4
End Sub
Si vous êtes interessé par comment je fais pour les attribuer dans un dossier en particulier n'hésitez pas à me demander, c'est avec plaisir que je partagerai la macro.
Bonne fin de journée,