Question

Je dois ajouter Cci destinataires à un courrier électronique chargé à partir d'un modèle. Les bénéficiaires doivent être tous les contacts dans une certaine catégorie. Je donne les résultats suivants jusqu'à présent, sauf qu'il est extrêmement inefficace et provoque Outlook pour ne pas répondre:

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
Était-ce utile?

La solution

Ce que je fini par faire se déplaçait newItem.Display vers le bas juste avant Set newItem = Nothing. Cela peut ne pas être la solution la plus efficace, mais il fait le travail sans causer un accident.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top