Saltar al contenido principal

¿Cómo guardar todos los archivos adjuntos de varios correos electrónicos en una carpeta en Outlook?

Es fácil guardar todos los archivos adjuntos de un correo electrónico con la función integrada Guardar todos los archivos adjuntos en Outlook. Sin embargo, si desea guardar todos los archivos adjuntos de varios correos electrónicos a la vez, no hay ninguna función directa que pueda ayudar. Debe aplicar repetidamente la función Guardar todos los archivos adjuntos en cada correo electrónico hasta que se guarden todos los archivos adjuntos de esos correos electrónicos. Eso lleva mucho tiempo. En este artículo, presentamos dos métodos para que guarde de forma masiva todos los archivos adjuntos de varios correos electrónicos en una carpeta específica fácilmente en Outlook.

Guarde todos los archivos adjuntos de varios correos electrónicos en una carpeta con código VBA
Varios clics para guardar todos los archivos adjuntos de varios correos electrónicos en una carpeta con una herramienta increíble


Guarde todos los archivos adjuntos de varios correos electrónicos en una carpeta con código VBA

Esta sección muestra un código VBA en una guía paso a paso para ayudarlo a guardar rápidamente todos los archivos adjuntos de varios correos electrónicos en una carpeta específica a la vez. Haz lo siguiente.

1. En primer lugar, debe crear una carpeta para guardar los archivos adjuntos en su computadora.

Entra en el Documentos carpeta y cree una carpeta llamada "Archivos adjuntos". Ver captura de pantalla:

2. Seleccione los correos electrónicos que guardará los archivos adjuntos y luego presione otro + F11 teclas para abrir el Microsoft Visual Basic para aplicaciones ventana.

3. Hacer clic en recuadro > Módulo para abrir el Módulo ventana y luego copie uno de los siguientes códigos VBA en la ventana.

Código 1 de VBA: guarde en bloque los archivos adjuntos de varios correos electrónicos (guarde los archivos adjuntos del mismo nombre directamente)

Tips: Este código guardará exactamente los mismos nombres adjuntos agregando los dígitos 1, 2, 3 ... después de los nombres de los archivos.

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
    VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
    Set xAttachments = xMailItem.Attachments
    xAttCount = xAttachments.Count
    xSaveFiles = ""
    If xAttCount > 0 Then
        For i = xAttCount To 1 Step -1
            GCount = 0
            xFilePath = xFolderPath & xAttachments.Item(i).FileName
            GFilepath = xFilePath
            xFilePath = FileRename(xFilePath)
            If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
                xAttachments.Item(i).SaveAsFile xFilePath
                If xMailItem.BodyFormat <> olFormatHTML Then
                    xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
                Else
                    xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
                End If
            End If
        Next i
    End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As FileSystemObject
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
    GCount = GCount + 1
    xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
    FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
    xHtml = xItem.HTMLBody
    xID = "cid:" & xCid
    If InStr(xHtml, xID) > 0 Then
        IsEmbeddedAttachment = True
    End If
End If
End Function
Código 2 de VBA: guarde en bloque los archivos adjuntos de varios correos electrónicos (verifique si hay duplicados)
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
Dim xYesNo As Integer
Dim xFlag As Boolean
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
    VBA.MkDir xFolderPath
End If
For Each xMailItem In xSelection
    Set xAttachments = xMailItem.Attachments
    xAttCount = xAttachments.Count
    xSaveFiles = ""
    If xAttCount > 0 Then
        For i = xAttCount To 1 Step -1
            xFilePath = xFolderPath & xAttachments.Item(i).FileName
            xFlag = True
            If VBA.Dir(xFilePath, 16) <> Empty Then
                xYesNo = MsgBox("The file is exists, do you want to replace it", vbYesNo + vbInformation, "Kutools for Outlook")
                If xYesNo = vbNo Then xFlag = False
            End If
            If xFlag = True Then
                xAttachments.Item(i).SaveAsFile xFilePath
                If xMailItem.BodyFormat <> olFormatHTML Then
                    xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
                Else
                    xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
                End If
            End If
        Next i
    End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

Notas:

1) Si desea guardar todos los archivos adjuntos del mismo nombre en una carpeta, aplique lo anterior Código 1 de VBA. Antes de ejecutar este código, haga clic en Herramientas > Referencias, y luego revisa el Tiempo de ejecución de secuencias de comandos de Microsoft en el cuadro Referencias - Proyecto caja de diálogo;

doc guardar adjuntos07

2) Si desea buscar nombres de archivos adjuntos duplicados, aplique el código VBA 2. Después de ejecutar el código, aparecerá un cuadro de diálogo para recordarle si debe reemplazar los archivos adjuntos duplicados, elija or No en función de sus necesidades.

5. presione el F5 clave para ejecutar el código.

Luego, todos los archivos adjuntos en los correos electrónicos seleccionados se guardan en la carpeta que creó en el paso 1. 

Notas: Puede haber un microsoft Outlook cuadro emergente, haga clic en el Permitir botón para seguir adelante.


Guarde todos los archivos adjuntos de varios correos electrónicos en una carpeta con una herramienta increíble

Si eres un novato en VBA, aquí recomendamos encarecidamente el Guardar todos los archivos adjuntos utilidad de Kutools para Outook para ti. Con esta utilidad, puede guardar rápidamente todos los archivos adjuntos de varios correos electrónicos a la vez con varios clics solo en Outlook.
Antes de aplicar la función, descargue e instale Kutools para Outlook en primer lugar.

1. Seleccione los correos electrónicos que contienen los archivos adjuntos que desea guardar.

Consejos: Puede seleccionar varios correos electrónicos no adyacentes manteniendo presionada la Ctrl clave y selecciónelos uno por uno;
O seleccione varios correos electrónicos adyacentes manteniendo presionada la Shift y seleccione el primer correo electrónico y el último.

2. Hacer clic en Kutools >Herramientas de adjuntoGuardar todo. Ver captura de pantalla:

3. En el Guardar configuración diálogo, haga clic en para seleccionar una carpeta para guardar los archivos adjuntos, y luego haga clic en el OK del botón.

3. Hacer clic en OK dos veces en el siguiente cuadro de diálogo emergente, luego todos los archivos adjuntos en los correos electrónicos seleccionados se guardan en la carpeta especificada a la vez.

Notas:

  • 1. Si desea guardar archivos adjuntos en diferentes carpetas según los correos electrónicos, marque la casilla Cree subcarpetas con el siguiente estilo cuadro y elija un estilo de carpeta en el menú desplegable.
  • 2. Además de guardar todos los archivos adjuntos, puede guardar archivos adjuntos según condiciones específicas. Por ejemplo, solo desea guardar los archivos adjuntos del archivo pdf cuyo nombre de archivo contiene la palabra "Factura", haga clic en el Opciones avanzadas para expandir las condiciones, y luego configure como se muestra la captura de pantalla a continuación.
  • 3. Si desea guardar automáticamente los archivos adjuntos cuando llegue el correo electrónico, Guardar archivos adjuntos automáticamente función puede ayudar.
  • 4. Para separar los archivos adjuntos directamente de los correos electrónicos seleccionados, Separar todos los archivos adjuntos característica de Kutools para Outlook puedo hacerte un favor

  Si desea tener una prueba gratuita (60 días) de esta utilidad, haga clic para descargarloy luego vaya a aplicar la operación según los pasos anteriores.


Artículos relacionados

Inserte archivos adjuntos en el cuerpo del mensaje de correo electrónico en Outlook
Normalmente, los archivos adjuntos se muestran en el campo Adjunto en un correo electrónico de redacción. Aquí, este tutorial proporciona métodos para ayudarlo a insertar fácilmente archivos adjuntos en el cuerpo del correo electrónico en Outlook.

Descargue / guarde automáticamente los archivos adjuntos de Outlook en una carpeta determinada
En términos generales, puede guardar todos los archivos adjuntos de un correo electrónico haciendo clic en Archivos adjuntos> Guardar todos los archivos adjuntos en Outlook. Pero, si necesita guardar todos los archivos adjuntos de todos los correos electrónicos recibidos y recibir correos electrónicos, ¿lo ideal? Este artículo presentará dos soluciones para descargar automáticamente archivos adjuntos de Outlook a una carpeta determinada.

Imprima todos los archivos adjuntos en uno o varios correos electrónicos en Outlook
Como sabe, solo imprimirá el contenido del correo electrónico, como el encabezado y el cuerpo, cuando haga clic en Archivo> Imprimir en Microsoft Outlook, pero no imprimirá los archivos adjuntos. Aquí le mostraremos cómo imprimir todos los archivos adjuntos en un correo electrónico seleccionado cómodamente en Microsoft Outlook.

Buscar palabras dentro del archivo adjunto (contenido) en Outlook
Cuando escribimos una palabra clave en el cuadro de búsqueda instantánea en Outlook, buscará la palabra clave en los asuntos, cuerpos, archivos adjuntos, etc. de los correos electrónicos. Pero ahora solo necesito buscar la palabra clave en el contenido del archivo adjunto solo en Outlook, ¿alguna idea? Este artículo le muestra los pasos detallados para buscar palabras dentro del contenido del archivo adjunto en Outlook fácilmente.

Mantenga los archivos adjuntos al responder en Outlook
Cuando reenviamos un mensaje de correo electrónico en Microsoft Outlook, los archivos adjuntos originales de este mensaje de correo electrónico permanecen en el mensaje reenviado. Sin embargo, cuando respondemos un mensaje de correo electrónico, los archivos adjuntos originales no se adjuntarán en el nuevo mensaje de respuesta. Aquí vamos a presentar un par de trucos para mantener los archivos adjuntos originales al responder en Microsoft Outlook.


Las mejores herramientas de productividad de oficina

Kutools para Outlook - Más de 100 potentes funciones para potenciar tu perspectiva

🤖 Asistente de correo AI: Correos electrónicos profesionales instantáneos con magia de IA: respuestas geniales con un clic, tono perfecto y dominio multilingüe. ¡Transforme el correo electrónico sin esfuerzo! ...

📧 Automatización de correo electrónico: Fuera de la oficina (disponible para POP e IMAP)  /  Programar envío de correos electrónicos  /  CC/CCO automático según reglas al enviar correo electrónico  /  Reenvío automático (reglas avanzadas)   /  Agregar saludo automáticamente   /  Divida automáticamente correos electrónicos de múltiples destinatarios en mensajes individuales ...

📨 Gestión de correo electrónico: Recuperar correos electrónicos fácilmente  /  Bloquear correos electrónicos fraudulentos por sujetos y otras personas  /  Eliminar correos electrónicos duplicados  /  Búsqueda Avanzada  /  Consolidar carpetas ...

📁 Archivos adjuntos profesionalesGuardar lote  /  Separación de lotes  /  Comprimir por lotes  /  Ahorro automático   /  Desconexión automática  /  Autocompresión ...

???? Interfaz mágica: 😊Más emojis bonitos y geniales   /  Aumente su productividad en Outlook con vistas con pestañas  /  Minimizar Outlook en lugar de cerrar ...

👍 Maravillas con un clic: Responder a todos los archivos adjuntos entrantes  /   Correos electrónicos antiphishing  /  🕘Mostrar zona horaria del remitente ...

👩🏼‍🤝‍👩🏻 Contactos y calendario: Agregar por lotes contactos de correos electrónicos seleccionados  /  Dividir un grupo de contactos en grupos individuales  /  Eliminar recordatorios de cumpleaños ...

Mas de Características 100 ¡Espere su exploración! Haga clic aquí para descubrir más.

Leer Mas       Descargar gratis      Comprar
 

 

Comments (81)
Rated 3.5 out of 5 · 3 ratings
This comment was minimized by the moderator on the site
Thank you for sharing the code. Unfortunately, I tried both with failure. This is what I got - The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros. Thank you.
This comment was minimized by the moderator on the site
Hi,
Please follow the instructions in the screenshot below to check if macros are enabled in the macro settings in your Outlook. After enabling both options, re-run the VBA code.

https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/macro-enabled.png
This comment was minimized by the moderator on the site
Thank you so much.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Thank you for sharing VBA code. This work like magic and is going to save it lots of time!
This comment was minimized by the moderator on the site
Hello friends!

Thanks for sharing this VBA code.

Is there any way to change the location of the save folder?

I share the pc with some colleagues and in this case I need the files to be saved in a password protected folder which is not located in the documents folder.

How can I make this change?

Thank you in advance
This comment was minimized by the moderator on the site
Hi Fabiana,
Change the line 14
xFolderPath = xFolderPath & "\Attachments\"

to
xFolderPath = "C:\Users\Win10x64Test\Desktop\save attachments\1\"

Here "C:\Users\Win10x64Test\Desktop\save attachments\1\" is the folder path in my case.
Don't forget to end the folder path with a slash "\"
This comment was minimized by the moderator on the site
Hello friends!

Thank you for sharing that VBA code.

Is there any way to change the location of the save folder?

I share the pc with some colleagues and in this case I need the files to be saved in a password protected folder which is not located in the documents folder.

How can I make this change?

Thank you in advance
This comment was minimized by the moderator on the site
If you are trying to run the Code that renames duplicate files and keep getting a "User Type Not Defined" error message here is the code fixed. Instead of the "Dim xFso As FileSystemObject" on line 47 it should be "Dim xFso As Variant"
Also added a Message Box to appear at the end of data transfer.

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
Set xAttachments = xMailItem.Attachments
xAttCount = xAttachments.Count
xSaveFiles = ""
If xAttCount > 0 Then
For i = xAttCount To 1 Step -1
GCount = 0
xFilePath = xFolderPath & xAttachments.Item(i).FileName
GFilepath = xFilePath
xFilePath = FileRename(xFilePath)
If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
xAttachments.Item(i).SaveAsFile xFilePath
If xMailItem.BodyFormat <> olFormatHTML Then
xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
Else
xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
End If
End If
Next i
End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
MsgBoX prompt:="File Transfer Complete", Title:="Sweatyjalapenos tha Goat"
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As Variant
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
GCount = GCount + 1
xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
xHtml = xItem.HTMLBody
xID = "cid:" & xCid
If InStr(xHtml, xID) > 0 Then
IsEmbeddedAttachment = True

End If
End If
End Function
This comment was minimized by the moderator on the site
Very nice script as of 2022-10-19 works great, for me doesn't seem to change original message by adding text. The only thing I changed is I added message received date time to each file name with the following format so it would nicely sort by date time in Windows folder: "yyyy-mm-dd HH-mm-ss ".

Code:

Dim GCount As Integer
Dim GFilepath As String
Public Sub SaveAttachments()
'Update 20200821
Dim xMailItem As Outlook.MailItem
Dim xAttachments As Outlook.Attachments
Dim xSelection As Outlook.Selection
Dim i As Long
Dim xAttCount As Long
Dim xFilePath As String, xFolderPath As String, xSaveFiles As String, xDateFormat As String
On Error Resume Next
xFolderPath = CreateObject("WScript.Shell").SpecialFolders(16)
Set xSelection = Outlook.Application.ActiveExplorer.Selection
xFolderPath = xFolderPath & "\Attachments\"
If VBA.Dir(xFolderPath, vbDirectory) = vbNullString Then
VBA.MkDir xFolderPath
End If
GFilepath = ""
For Each xMailItem In xSelection
Set xAttachments = xMailItem.Attachments
xAttCount = xAttachments.Count
xSaveFiles = ""
If xAttCount > 0 Then
For i = xAttCount To 1 Step -1
GCount = 0
xDateFormat = Format(xMailItem.ReceivedTime, "yyyy-mm-dd HH-mm-ss ")
xFilePath = xFolderPath & xDateFormat & xAttachments.Item(i).FileName
GFilepath = xFilePath
xFilePath = FileRename(xFilePath)
If IsEmbeddedAttachment(xAttachments.Item(i)) = False Then
xAttachments.Item(i).SaveAsFile xFilePath
If xMailItem.BodyFormat <> olFormatHTML Then
xSaveFiles = xSaveFiles & vbCrLf & "<Error! Hyperlink reference not valid.>"
Else
xSaveFiles = xSaveFiles & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>"
End If
End If
Next i
End If
Next
Set xAttachments = Nothing
Set xMailItem = Nothing
Set xSelection = Nothing
End Sub

Function FileRename(FilePath As String) As String
Dim xPath As String
Dim xFso As FileSystemObject
On Error Resume Next
Set xFso = CreateObject("Scripting.FileSystemObject")
xPath = FilePath
FileRename = xPath
If xFso.FileExists(xPath) Then
GCount = GCount + 1
xPath = xFso.GetParentFolderName(GFilepath) & "\" & xFso.GetBaseName(GFilepath) & " " & GCount & "." + xFso.GetExtensionName(GFilepath)
FileRename = FileRename(xPath)
End If
xFso = Nothing
End Function

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xItem As MailItem
Dim xCid As String
Dim xID As String
Dim xHtml As String
On Error Resume Next
IsEmbeddedAttachment = False
Set xItem = Attach.Parent
If xItem.BodyFormat <> olFormatHTML Then Exit Function
xCid = ""
xCid = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCid <> "" Then
xHtml = xItem.HTMLBody
xID = "cid:" & xCid
If InStr(xHtml, xID) > 0 Then
IsEmbeddedAttachment = True
End If
End If
End Function
This comment was minimized by the moderator on the site
Hi Oigo,
This is a very useful VBA script. Thank you for sharing it.
This comment was minimized by the moderator on the site
Hi crystal,

sorry for not being clear.

I was trying to use the code above mentioned. However, apparently I was doing something wrong. I was thinking that I might need to amend some parts in the code shown. For instance the path where to save the attachments and maybe some other parts. Therefore I was asking if you could share the code highlighting the parts which needs tailoring and how to tailor them.

Many thanks,
BR
This comment was minimized by the moderator on the site
Hi Rokkie,
Did you get any error prompt when the code runs? Or which line in your code is highlighted? I need more details so I can see where you can modify the code.
This comment was minimized by the moderator on the site
Hey crystal,

completeley new to this VBA. Can you share a code to use which shows where I have to amend with an example? As a Rookie it is a bit difficult to figure it out.

I am working via a Ctrix connection. Could this be a blocker for the macro?

Much appreaciate the help.
This comment was minimized by the moderator on the site
Hi Rookie,
Sorry I don't understand what you mean: "Can you share a code to use which shows where I have to amend with an example?"
And the code operates on selected emails in Outlook, Ctrix Connection does not block the macro.
This comment was minimized by the moderator on the site
Hi, I am running this Code 1 to extract .txt files from separate sub-folders of an inbox. It works great out of one sub-folder but not at all out of another sub-folder. I have tried forwarding the relevant email and attachment into other inboxes but no luck. The files are automatically generated and sent to the different sub-folders and only vary by a single letter in their title

Any help much is appreciated
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations