Pregunta

Tengo que añadir destinatarios CCO a un correo electrónico cargado de una plantilla. Los destinatarios deben ser todos los contactos en una categoría determinada. Tengo el siguiente hasta ahora, excepto que es extremadamente ineficiente y hace que Outlook deje de responder:

Sub Distribute_Newsletter()
Set newItem = Application.CreateItemFromTemplate("P:\Subscription Templates\subscription template.oft")
newItem.Display

Set oNS = Application.GetNamespace("MAPI")
Set oContacts = oNS.Folders(1).Folders("Contacts")
Dim emailAddress As String

For Each oContactItem In oContacts.Items
    If oContactItem.Class = olContact Then
        emailAddress = oContactItem.Email1Address
        If Not emailAddress = "" Then 'And oContactItem.Categories
            Set objRecip = newItem.Recipients.Add(emailAddress)
            objRecip.Type = olBCC
        End If
    End If
Next

Set oNS = Nothing
Set oContacts = Nothing
Set objRecip = Nothing
Set newItem = Nothing
End Sub
¿Fue útil?

Solución

Lo que terminé haciendo fue moviendo newItem.Display hasta justo antes de Set newItem = Nothing. Esto puede no ser la solución más eficiente, pero hace el trabajo sin causar un accidente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top