Outlook Enregistrer les pièces jointes de nombreux e-mails à la fois dans Outlook?

Anthony_51

XLDnaute Nouveau
Bonjour à tous,

Désolé d'avance, c'est ma première discussion que je crée sur le forum ;-)

Je suis comptable et depuis le premier confinement nous recevons quasiment toutes nos factures par mail.
J'ai cherché sur internet et j'ai trouvé une macro qui me permet de sélectionner les mails et d'en extraire les pièces jointes ce qui m'aide déjà beaucoup.
Mais cette macro enregistre les fichiers dans "Mes documents" dossier "OLAttachments" alors que je souhaiterais quelle les enregistre sur le réseau de mon entreprise \\xxxxxx\xxxx\Compta Géné\Factures à transférer\xxxx
Pouvez-vous m'aider svp ?

Ci-dessous le code que j'utilise :

Public Sub SaveAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
Dim Index As Long

Index = 1

' Get the path to your My Documents folder
strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
On Error Resume Next

' Instantiate an Outlook Application object.
Set objOL = CreateObject("Outlook.Application")

' Get the collection of selected objects.
Set objSelection = objOL.ActiveExplorer.Selection

' The attachment folder needs to exist
' You can change this to another folder name of your choice

' Set the Attachment folder.
strFolderpath = strFolderpath & "\OLAttachments\"

' Check each selected item for attachments.
For Each objMsg In objSelection

Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count

If lngCount > 0 Then

' Use a count down loop for removing items
' from a collection. Otherwise, the loop counter gets
' confused and only every other item is removed.

For i = lngCount To 1 Step -1

' Get the file name.
strFile = objAttachments.Item(i).FileName

' Combine with the path to the Temp folder.
strFile = strFolderpath & Index & "_" & strFile

' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strFile

Index = Index + 1

Next i
End If

Next

ExitSub:

Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub

J'espère avoir fait comme il fallait ;-)
Merci d'avance
Bonne journée
Anthony
 

Etoto

XLDnaute Barbatruc
Bonjour,
strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
strFolderpath = strFolderpath & "\OLAttachments\"
Je suis mauvais en VBA mais le seul truck que je sais sur ton code, c'est que c'est ces deux lignes qui choisissent le chemin. Alors c'est celle-ci qu'il faut changer.

D'ailleurs c'est dit la dedans :
Get the path to your My Documents folder
qui veux dire :
Obtenez le chemin d'accès à votre dossier Mes documents

Set the Attachment folder
Qui veut dire :
Définir le dossier des pièces jointes
 

Discussions similaires

Statistiques des forums

Discussions
312 104
Messages
2 085 344
Membres
102 865
dernier inscrit
FreyaSalander