如何在 Excel VBA 中访问联系人组? [英] How to access contact groups in Excel VBA?
本文介绍了如何在 Excel VBA 中访问联系人组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在构建一个 Excel 插件,它将活动工作簿作为 Outlook 电子邮件模板中的附件发送到特定的联系人组.
I am building an Excel add-in that sends the active workbook as an attachment in an Outlook email template to a specific Contact Group.
我已经获得了前两部分来处理下面的代码,但我不确定如何将 .TO
字段设置为联系人组.
I've gotten the first two parts to work with the code below, but I am not sure how to set the .TO
field to a contact group.
Public Sub Mail_Reports()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
On Error Resume Next
Set OutApp = CreateObject("Outlook.Application")
'Set this line to the path and file name of your template
Set OutMail = OutApp.CreateItemFromTemplate("C:UsersmosesAppDataRoamingMicrosoftTemplates est.oft")
On Error Resume Next
With OutMail
'.TO field should be set to the contact group
.BCC = ""
.Attachments.Add ActiveWorkbook.FullName
.HTMLBody = Replace(OutMail.HTMLBody, strOldPeriod, strNewPeriod)
.Subject = Replace(OutMail.Subject, strOldPeriod, strNewPeriod)
'To display the email leave as is; to send the Email, change to .Send
.Display 'or Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
推荐答案
只需使用联系人组的名称(以前称为分发列表").我只是按照 Ron de Bruin's 网站上的建议尝试过,并且它有效.
Just use the name of the contact group (formerly called "distribution lists"). I just tried it, as suggested on Ron de Bruin's site, and it works.
这篇关于如何在 Excel VBA 中访问联系人组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文