题
我需要将BCC收件人添加到从模板中加载的电子邮件中。接收者应是特定类别中的所有联系人。到目前为止,我有以下内容,除了它极低效率,并且使前景变得无反应:
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
. 。这可能不是最有效的解决方案,但是它可以完成工作而不会导致崩溃。
不隶属于 StackOverflow