다음 코드는 ObjMail이 작성중인 메시지라고 가정합니다. 직원에게 보낸
' Delete any existing reply recipients
Do While ObjMail.ReplyRecipients.Count > 0
ObjMail.ReplyRecipients.Remove 1
Loop
' Add the new recipient
ObjMail.ReplyRecipients.Add "[email protected]"
' Send blind copy to other staff members
ObjMail.BCC = "Staff1.isp.com, Staff2.isp.com, Staff3.isp.com"
메시지는 생일 메시지를 보내는 누구로부터 온 말할 것이다. 하지만 누구나 답장을 보내면받는 사람은 "[email protected]"이됩니다.
나는 다른 직원에게 시각 장애 사본을 보냈습니다. 직원 목록이 비밀이기 때문에가 아니라 다음과 같은 이유 때문입니다.
- 주소 당 평균 20 자의 직원이있는 경우 CC를 사용하면 각 500 자 메시지에 10,000자를 추가합니다.
- 다른 500 * 500 개의 메시지를 저장하고 싶을 때 담당자가 Reply All을 사용하는 것을 방지합니다.
- 회사 서버를 채우기를 원하면 ObjMail.CC를 사용하십시오.
나는 수천 명의 직원이 전국에 흩어져있는 영어 NHS에서 수년 전에 일했기 때문에 메시지 크기가 걱정됩니다. 소규모 병원의 누군가가 병원 내에서 판매 할 자전거 광고를하려했지만 해당 국가의 모든 직원에게 광고를하도록 관리했습니다. 나는 느린 전화 접속 회선으로 집에서 일했다. 이 메시지를 다운로드하는 데 30 분의 시간이 걸렸습니다. 나는 내 대답을 테스트하는 데 사용되는 전체 루틴을 포함 아래 응답
새로운 섹션
일상적인 테스트의 전체 코드를 요청합니다. 그것은 또 다른 대답을 위해 작성한 일상에서 수정되었습니다. 그것은 원하지 않을 수도있는 HTML 본문을 생성하지만 그렇게 할 수있는 방법을 보여줍니다. 나는 나의 테스트에 사용 된 실제 이메일 주소를 더미 주소로 대체했다. 그렇지 않으면 변경되지 않습니다.
Sub ReplyToRecipientWithBlindCopies()
' Create a mail item with a simple message.
' Send the mail item to "[email protected]" 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 "[email protected]"
.ReplyRecipients.Add "[email protected]"
' You will need to replace this with a loop
' to add all your staff members.
.BCC = "[email protected], [email protected], [email protected]"
' 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
줄의 시작 부분에 공백이 있으면 줄은 코드로 서식이 지정됩니다. 질문을 읽을 수 있도록 공백을 삭제했습니다. –
[무엇을 시도 했습니까?] (http://mattgemmell.com/2008/12/08/what-have-you-tried/) –