VBA Outlook Enregistrement fichier

Bonjour à tous,

J'essaie activement d'écrire une macro sur Outlook permettant d'enregistrer toutes les pj d'un mail que je reçois quotidiennement (et qui selon une règle est placé dans un dossier Outlook à sa réception), dans un dossier de mon ordinateur et de manière automatique. Existe-t-il une telle solution?

Merci beaucoup,

Hello,

Un sujet résolu qui traite du même sujet, peut être tu y trouveras ton bonheur :

https://forum.excel-pratique.com/excel/macro-enregistrer-piece-jointe-outlook-t55473.html

Merci. Très utile. J'ai donc pu récupérer une macro qui marche. Cependant, j'aimerais que cette macro s'exécute dès réception du mail, de manière automatique. De plus, cette macro me demande à chaque exécution de confirmer le dossier de sauvegarde des pj, je ne sais pas comment retirer cela.

Merci bcp!

Sub SaveAttachment()

'Declaration
Dim myItems, myItem, myAttachments, myAttachment As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim i As Integer

'Boîte de dialogue simple pour le chemin de sauvegarde
myOrt = InputBox("Destination", "Save Attachments", "Z:\Personnel\test outlook VBA\")

On Error Resume Next

'Actions sur les objets sélectionnés
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection

'boucle
For Each myItem In myOlSel
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then

'for all attachments do...
For i = 1 To myAttachments.Count

'save them to destination
myAttachments(i).SaveAsFile myOrt & _
myAttachments(i).DisplayName
myItem.Body = myItem.Body & _
"File: " & myOrt & _
myAttachments(i).DisplayName & vbCrLf

Next i

End If

Next

Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing

End Sub

Pb résolu! merci bcp!

Rechercher des sujets similaires à "vba outlook enregistrement fichier"