以下代码假定 ObjMail 是您正在创建的邮件。
' Delete any existing reply recipients
Do While ObjMail.ReplyRecipients.Count > 0
ObjMail.ReplyRecipients.Remove 1
Loop
' Add the new recipient
ObjMail.ReplyRecipients.Add "BirthdayPerson@isp.com"
' Send blind copy to other staff members
ObjMail.BCC = "Staff1.isp.com, Staff2.isp.com, Staff3.isp.com"
发送给员工的消息会说它来自发送生日消息的人。但如果有人回复,收件人将是“BirthdayPerson@isp.com”。
我已将密件副本发送给其他工作人员。这不是因为员工名单是秘密的,而是因为:
- 如果您有 500 名员工,每个地址平均包含 20 个字符,则使用抄送将为 500 条消息中的每条添加 10,000 个字符。
- 它可以防止员工在添加他们最好的祝福时使用“全部回复”来保存另外 500 * 500 条消息。
- 如果您希望填写公司的服务器,请使用 ObjMail.CC。
我担心消息的大小,因为多年前我曾在英国 NHS 工作,该机构有数千名员工分散在全国各地。一家小医院的某个人试图在医院内为他的自行车做广告,但设法向全国的每一位员工做广告。我在家工作,拨号速度很慢;下载这条消息花了半个小时。
应要求提供测试例程完整代码的新部分
下面是我用来测试答案的完整例程。它改编自我为另一个答案编写的例程。它会创建一个您可能不想要的 HTML 正文,但会向您展示如果您这样做的话。我已将用于测试的真实电子邮件地址替换为虚拟地址;否则不变。
Sub ReplyToRecipientWithBlindCopies()
' Create a mail item with a simple message.
' Send the mail item to "BirthdayPerson@isp.com" and make them
' the recipient of any replies.
' Send blind copies to all other recipients.
' Author: Tony Dallimore, York, England
Dim OlApp As Outlook.Application
Dim ObjMail As Outlook.MailItem
Dim MessageBody As String
' This creates a blue message on a grey background. This is a
' demonstration of what is possible; not a recommendation!
MessageBody = "<table width=""100%"" style=""Color:#0000FF;" & _
" background-color:#F0F0F0;""><tr><td align= ""center"">" & _
"Happy birthday from all your colleagues!</td></tr></table>"
Set OlApp = Outlook.Application
Set ObjMail = OlApp.CreateItem(olMailItem)
With ObjMail
.BodyFormat = olFormatHTML
.Subject = "Happy birthday!"
.HTMLBody = HeadAndBodyToHtmlDoc("", MessageBody)
' Remove any existing recipients
Do While .Recipients.Count > 0
.Recipients.Remove 1
Loop
' Remove any existing reply recipients
Do While .ReplyRecipients.Count > 0
.ReplyRecipients.Remove 1
Loop
' Add birthday person to Recipient and ReplyRecipient lists
.Recipients.Add "BirthdayPerson@isp.com"
.ReplyRecipients.Add "BirthdayPerson@isp.com"
' You will need to replace this with a loop
' to add all your staff members.
.BCC = "Staff1@isp.com, Staff2@isp.com, Staff3@isp.com"
' Display the prepared messages ready for any final changes.
' The user must send it.
.Display
End With
End Sub
Function HeadAndBodyToHtmlDoc(Head As String, Body As String) As String
' Wrap Head and Body created by caller in a standard envelope.
' Author: Tony Dallimore, York, England
HeadAndBodyToHtmlDoc = _
"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Frameset//EN""" & _
" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"">" & _
vbCr & vbLf & "<html xmlns=""http://www.w3.org/1999/xhtml""" & _
" xml:lang=""en"" lang=""en"">" & vbCr & vbLf & "<head><meta " & _
"http-equiv=""Content-Type"" content=""text/html; " & _
"charset=utf-8"" />" & vbCr & vbLf & Head & vbCr & vbLf & _
"</head><body>" & vbCr & vbLf & Body & "</body></html>"
End Function