質問

テンプレートからロードされた電子メールにBCCレシピエントを追加する必要があります。受信者は、特定のカテゴリのすべての連絡先である必要があります。これまでのところ、私は以下を持っていますが、それは非常に非効率的であり、Outlookが反応しなくなることを除きます。

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
役に立ちましたか?

解決

私がやったことは動くことでした newItem.Display 直前に Set newItem = Nothing. 。これは最も効率的なソリューションではないかもしれませんが、クラッシュを引き起こすことなくジョブが完了します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top