Saltar al contenido principal

¿Cómo enumerar todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico en Outlook?

¿Hay alguna buena forma de insertar todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico en Outlook? En este artículo, hablaré sobre cómo resolver este trabajo en Outlook.

Enumere todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico con código VBA

Enumere todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico con una función simple


Enumere todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico con código VBA

Siga los siguientes pasos para completar esta tarea:

1. Mantenga pulsado el ALT + F11 teclas para abrir el Microsoft Visual Basic para aplicaciones ventana.

2. En la Microsoft Visual Basic para aplicaciones ventana, haga doble clic Esta sesión de Outlook del desplegable Proyecto1 (VbaProject.OTM) panel para abrir el modo y luego copie y pegue el siguiente código en el módulo en blanco.

Código de VBA: enumere todos los nombres de archivos adjuntos en el cuerpo del mensaje:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim xMailItem As MailItem
    If Item.Class = olMail Then
        Set xMailItem = Item
        If xMailItem.Attachments.Count > 0 Then
          AddAttachmentNamesToBody
        End If
    End If
    End Sub

3. Luego sigue haciendo clic recuadro > Módulo, copie y pegue el código siguiente en el módulo en blanco abierto, vea la captura de pantalla:

Código de VBA: enumere todos los nombres de archivos adjuntos en el cuerpo del mensaje:

Public Sub AddAttachmentNamesToBody()
    Dim xMailItem As MailItem
    Dim xAttachment As Attachment
    Dim xFileName As String
   Dim xInspector As Outlook.Inspector
    Dim xDoc As Word.Document
    Dim xWdSelection As Word.Selection
    On Error Resume Next
    Set xMailItem = Outlook.ActiveInspector.CurrentItem
    If xMailItem.Attachments.Count = 0 Then
        Exit Sub
    End If
    xFileName = ""
    For Each xAttachment In xMailItem.Attachments
        If xFileName = "" Then
            xFileName = " <" & xAttachment.FileName & "> "
        Else
            xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "
        End If
    Next xAttachment
    Set xInspector = Outlook.Application.ActiveInspector()
    Set xDoc = xInspector.WordEditor
    Set xWdSelection = xDoc.Application.Selection
    xWdSelection.HomeKey Unit:=wdStory
    xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf
    Set xMailItem = Nothing
    End Sub

4. Y luego haz clic Herramientas > Referencias existentes Microsoft Visual Basic para aplicaciones ventana, en el aparecido Referencias-Proyecto1 cuadro de diálogo, comprobar Biblioteca de objetos de Microsoft Word Opción de la Referencias disponibles cuadro de lista, ver captura de pantalla:

5. Hacer clic OK para salir del cuadro de diálogo, entonces debe agregar el botón de macro en el Acceso rapido a la barra de herramientas. En el nuevo Mensaje ventana, elija Más comandos del desplegable Personalizar la barra de herramientas de acceso rápido desplegable, ver captura de pantalla:

6. En la Opciones de outlook cuadro de diálogo, realice las siguientes operaciones:

(1.) Seleccione Macros del desplegable Elija comandos de la lista desplegable;

(2.) Haga clic en el nombre de la macro que acaba de insertar;

(3.) Y luego haga clic en Añada para agregar la macro al Personalizar la barra de herramientas de acceso rápido.

7. Luego haga clic OK para cerrar el cuadro de diálogo, ahora, el botón de macro se ha insertado en el Acceso rapido a la barra de herramientas, ver captura de pantalla:

8. Ahora, cuando cree un mensaje nuevo y haga clic en el botón de macro, los nombres de los archivos adjuntos se insertarán encima del cuerpo del mensaje como se muestra a continuación:


Enumere todos los nombres de los archivos adjuntos en el cuerpo del mensaje al redactar un correo electrónico con una función simple

Puede ser que el código anterior le resulte algo difícil de aplicar, si tiene Kutools para Outlook, Con su Copiar nombres función, puede copiar rápidamente los nombres de los archivos adjuntos de un mensaje y pegarlos en cualquier lugar que necesite.

Nota: Para aplicar esto Copiar nombres, en primer lugar, debe descargar el Kutools para Outlooky, a continuación, aplique la función de forma rápida y sencilla.

Después de instalar Kutools para Outlook, haz lo siguiente:

1. Primero, cree el nuevo correo electrónico que necesita y luego haga clic en Kutools > Copiar nombres en el nuevo Mensaje ventana, ver captura de pantalla:

2. Y luego, aparecerá un cuadro emergente para recordarle que los nombres de los archivos adjuntos se han copiado al portapapeles, vea la captura de pantalla:

3. Ahora solo necesitas presionar Ctrl + V teclas juntas para pegar los nombres de los archivos adjuntos en el cuerpo del mensaje que necesita, vea la captura de pantalla:


Artículos más relativos:

  • Responder a todos con archivos adjuntos originales en Outlook
  • Normalmente, cuando aplica la función Responder a todos para responder el mensaje a todos los destinatarios en Outlook, los archivos adjuntos originales se perderán automáticamente. ¿Es posible adjuntar archivos adjuntos originales al responder a todos en Outlook?
  • Descargar/guardar 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.
  • Cambiar la ubicación predeterminada para guardar archivos adjuntos en Outlook
  • ¿Está harto de encontrar la ubicación del archivo adjunto que ha especificado cada vez que inicia Outlook? En este tutorial, le mostraremos cómo cambiar la ubicación predeterminada del archivo adjunto. Después de eso, la carpeta para guardar archivos adjuntos especificada se abrirá automáticamente cada vez que guarde los archivos adjuntos aunque reinicie Outlook.
  • Eliminar todos los archivos adjuntos del correo electrónico en Outlook
  • Normalmente, cuando obtiene una vista previa de un correo electrónico, puede eliminar un archivo adjunto haciendo clic derecho y seleccionando el elemento Eliminar archivo adjunto. A veces puede haber muchos archivos adjuntos en un mensaje de correo electrónico y será tedioso eliminarlos uno por uno. Aquí le presentamos dos trucos sencillos para eliminar todos los archivos adjuntos en un correo electrónico y eliminar todos los archivos adjuntos de varios correos electrónicos también en 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 (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Why am I getting "user-defined type not defined" when I get to Step 8?
This comment was minimized by the moderator on the site
Why am I getting "user-defined type not defined" when I get to Step 8?
This comment was minimized by the moderator on the site
When I do this, it always put the attachments at the beginning of the message, no matter where my cursor is located. I then have to copy/paste to the bottom of the email. Is there a way to change that?
This comment was minimized by the moderator on the site
Hello, VMS,
If you want to put the attachments at the the position of your cursor, please replace the second code with following code:

Public Sub AddAttachmentNamesToBody()

Dim xMailItem As MailItem

Dim xAttachment As Attachment

Dim xFileName As String

Dim xInspector As Outlook.Inspector

Dim xDoc As Word.Document

Dim xWdSelection As Word.Selection

On Error Resume Next

Set xMailItem = Outlook.ActiveInspector.CurrentItem

If xMailItem.Attachments.Count = 0 Then

Exit Sub

End If

xFileName = ""

For Each xAttachment In xMailItem.Attachments

If xFileName = "" Then

xFileName = " <" & xAttachment.FileName & "> "

Else

xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "

End If

Next xAttachment

Set xInspector = Outlook.Application.ActiveInspector()

Set xDoc = xInspector.WordEditor

Set xWdSelection = xDoc.Application.Selection

xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf

Set xMailItem = Nothing

End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
That worked! Now another favor... How do I exclude certain file types or names? My required company signature contains a PNG file that I would like to exclude.Thank you!!
This comment was minimized by the moderator on the site
To exclude some specific files, please apply the below code, please try it.
Public Sub AddAttachmentNamesToBody()

Dim xMailItem As MailItem

Dim xAttachment As Attachment

Dim xFileName As String

Dim xInspector As Outlook.Inspector

Dim xDoc As Word.Document

Dim xWdSelection As Word.Selection

Dim xExt As String

Dim xFound As Boolean

Dim xExtArr As Variant

On Error Resume Next

xExtArr = Array("docx", "exe") 'change the file extension you want to exclude

Set xMailItem = Outlook.ActiveInspector.CurrentItem

If xMailItem.Attachments.Count = 0 Then

Exit Sub

End If

xFileName = ""

For Each xAttachment In xMailItem.Attachments

xExt = VBA.Mid(xAttachment.FileName, VBA.InStrRev(xAttachment.FileName, ".") + 1)

xFound = False

For i = LBound(xExtArr) To UBound(xExtArr)

If xExt = xExtArr(i) Then

xFound = True

Exit For

End If

Next

If xFound = False Then

If xFileName = "" Then

xFileName = " <" & xAttachment.FileName & "> "

Else

xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "

End If

End If

Next xAttachment

Set xInspector = Outlook.Application.ActiveInspector()

Set xDoc = xInspector.WordEditor

Set xWdSelection = xDoc.Application.Selection

xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf

Set xMailItem = Nothing

End Sub
This comment was minimized by the moderator on the site
when I tried this code it sends the attachment names in every email that has attachments.
I want it to only do it when I click the macro.

How do I amend the code to do just that?
This comment was minimized by the moderator on the site
I also don't know how to fix it. Anyone could hep on that?
This comment was minimized by the moderator on the site
This is wonderful -- thank you! Is there also a way to somehow view all the attachment names in an email that has been sent to you from someone else (i.e. received)? For some reason, the file names are not displaying in full unless you hover, which is ridiculous when you regularly have 15 files to sort through.
This comment was minimized by the moderator on the site
Hello,
To List all attachment names in an received email, please copy and pase the below VBA code into the ThisOutlookSession module of the Microsoft Visual Basic for Applications window:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim xEIDArr As Variant, xEID As Variant, xItem As Object
Dim xAttachment As Attachment
Dim xFileName As String
On Error Resume Next
xEIDArr = Split(EntryIDCollection, ",")
For Each xEID In xEIDArr
Set xItem = Session.GetItemFromID(xEID)
If xItem.Class = olMail Then
xFileName = ""
For Each xAttachment In xItem.Attachments
If IsEmbeddedAttachment(xAttachment) = False Then
If xFileName = "" Then
xFileName = " " & "<" & xAttachment.FileName & ">"
Else
xFileName = xFileName & "
" & " " & "<" & xAttachment.FileName & ">"
End If
End If
Next xAttachment
If xFileName = "" Then Exit Sub
xFileName = "Attachments: " & "
" & xFileName & "
" & "
"
xItem.HTMLBody = "" & xFileName & "" & xItem.HTMLBody
xItem.Save
End If
Next
Set xItem = Nothing
End Sub

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xAttParent As Object
Dim xCID As String, xID As String
Dim xHTML As String
On Error Resume Next
Set xAttParent = Attach.Parent
xCID = ""
xCID = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCID <> "" Then
xHTML = xAttParent.HTMLBody
xID = "cid:" & xCID
If InStr(xHTML, xID) > 0 Then
IsEmbeddedAttachment = True
Else
IsEmbeddedAttachment = False
End If
End If
End Function

After pasting this code, when new emails with attachments arriving in your Outlook, the attachment names will be listed at the top of the message body automatically.
Please try it, hope it can help you!
This comment was minimized by the moderator on the site
this is great. Is there any way to merge this with VMS's request above to exclude some specific files included in signatures (.png, .jpg, etc.)?
This comment was minimized by the moderator on the site
Great, thanks for that. I wonder if it is possible that the list of attachments is only attached when I write to a specific email address?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations