我試圖在Excel表單上設置幾個按鈕來向不同的人羣發送電子郵件。我在單獨的工作表上創建了多個單元格範圍,以列出單獨的電子郵件地址。例如,我想要「按鈕A」打開Outlook並將「工作表B:單元格D3-D6」中的電子郵件地址列表。然後,所有必須完成的操作都是在Outlook中點擊「發送」。我如何使用Outlook將電子郵件發送給Excel中的多個收件人VBA
這是我的VBA代碼到目前爲止,但我不能得到它的工作。有人能告訴我我錯過了什麼或者錯了嗎?
VB:
Sub Mail_workbook_Outlook_1()
'Working in 2000-2010
'This example send the last saved version of the Activeworkbook
Dim OutApp As Object
Dim OutMail As Object
EmailTo = Worksheets("Selections").Range("D3:D6")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = EmailTo
.CC = "[email protected];[email protected]"
.BCC = ""
.Subject = "RMA #" & Worksheets("RMA").Range("E1")
.Body = "Attached to this email is RMA #" & Worksheets("RMA").Range("E1") & ". Please follow the instructions for your department included in this form."
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Display
End With
On Error Goto 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
你也可以使用[Recipient.Add](http://stackoverflow.com/questions/13019651/automated-email-generation-not-resolving-multiple-收件人) – SeanC 2013-02-20 17:05:37