Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Adjutar Archivos en Correo Masivo Combinar Correspondencia
Adjutar Archivos en Correo Masivo Combinar Correspondencia
excelente, pero limitada cuando nos enfrentamos a un lista de, por ejemplo, 100 emails
personalizados con 1 archivo diferente para cada destinatario… Por defecto, la combinación no se
puede hacer, pero si trabajamos un poco, podremos preparar una macro que haga el trabajo por
nosotros.
Tiene varias limitaciones de formato, pero es un mal menor con el que tendremos que vivir… El
tiempo que nos ahorraremos suplirá el inconveniente de no poder añadir una imagen de cabecera
en el email, no?
En primer lugar, vamos a tener que localizar la pestaña programador en Word (entra en este
enlace si no la encuentras). En Opciones de Word…
Aceptamos, cerramos y ya vemos la ficha programador en la cinta de opciones… nos centramos en
el primer bloque de opciones.
Vamos a vaciarla y pegarle este código que tenemos aquí abajo (os marco en rojo la dirección de
email, que deberéis cambiar por la vuestra para evitar posibles errores):
Sub combina()
Dim Source As Document, Maillist As Document, TempDoc As Document
Dim Datarange As Range
Dim i As Long, j As Long
Set objEmail = CreateObject("CDO.Message")
objEmail.from = "info@educadictos.com"
Dim bStarted As Boolean
Set oOutlookApp = CreateObject("Outlook.Application")
' Dim oItem As Outlook.MailItem
Dim mysubject As String, message As String, title As String
Set Source = ActiveDocument
' Check if Outlook is running. If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
' Open the catalog mailmerge document
With Dialogs(wdDialogFileOpen)
.Show
End With
Set Maillist = ActiveDocument
' Show an input box asking the user for the subject to be inserted into the email messages
message = "Escribe el asunto que llevarán todos los emails" ' Set prompt.
title = " Email Subject Input" ' Set title.
' Display message, title
mysubject = InputBox(message, title)
' Iterate through the Sections of the Source document and the rows of the catalog mailmerge
document,
' extracting the information to be included in each email.
For j = 1 To Source.Sections.Count - 1
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Subject = mysubject
.Body = Source.Sections(j).Range.Text
Set Datarange = Maillist.Tables(1).Cell(j, 1).Range
Datarange.End = Datarange.End - 1
.To = Datarange
For i = 2 To Maillist.Tables(1).Columns.Count
Set Datarange = Maillist.Tables(1).Cell(j, i).Range
Datarange.End = Datarange.End - 1
.Attachments.Add Trim(Datarange.Text), olByValue, 1
Next i
.Send
End With
Set oItem = Nothing
Next j
Maillist.Close wdDoNotSaveChanges
' Close Outlook if it was started by this macro.
If bStarted Then
oOutlookApp.Quit
End If
MsgBox Source.Sections.Count - 1 & " messages have been sent."
'Clean up
Set oOutlookApp = Nothing
End Sub
Documento 2: Otro word con una tabla de 2 columnas, una con el email del destinatario
(que ha de coincidir con uno de los destinatarios del documento 1, lógicamente), y otra
con la ruta en tu ordenador del documento que ha de recibir. Y una fila por cada
destinatario… algo así:
3. La macro nos pedirá que le indiquemos dónde está el Documento 2, así que lo llevamos
hasta el nuestro y le damos a aceptar. (Este documento tiene que estar cerrado, o la
macro dará error).
4. Ahora nos pide que añadamos el asunto que llevarán los emails. Aceptamos y listo… Si no
tenemos Outlook abierto, lo abrirá, y si ya lo tenemos abierto, irá enviando los emails con
los adjuntos rápidamente hasta darnos el resultado de los envíos. Una vez termine, si
Outlook estaba abierto, lo dejará abierto, y si estaba cerrado, lo cerrará.
Podéis hacer las pruebas para combinar correspondencia vosotros mismos, veréis que es una
macro impresionante