我正在尝试向收件人发送一封自定义的电子邮件给超过一百个收件人。
我现在可以向一个人发送电子邮件,但我不知道如何为多个收件人循环并更改其中的内容。
我有类似的东西但它有效,但我不知道如何继续
With OutlookMailItem
.To = Range("O2").Value
.Subject = "Promotion campaign"
.Body = "Dear Sir/Madam," & vbNewLine & vbNewLine & _
"You are eligible for & Range("A2").Value & _
"Please follow the instruction below to redeem your gift"
答案 0 :(得分:2)
在这类问题中寻找解决方案的好地方是: https://www.rondebruin.nl/win/s1/outlook/amail8.htm
在您的下方,我会找到您想要实现的代码。
<强>假设:强>
.Body
现在我使用只显示所有电子邮件的.Display
方法,但如果您将其更改为.Send
,则会自动发送这些邮件而不显示这些邮件
Sub Send_Row_Or_Rows_Attachment_1()
'Working in 2000-2016
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Dim intHowManyRows As Integer
With Application
.ScreenUpdating = False
End With
intHowManyRows = Application.Range("A1").CurrentRegion.Rows.Count
For r = 1 To intHowManyRows
'Save, Mail, Close and Delete the file
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Cells(r, 1).Value
.Subject = Cells(r, 3).Value
'.Attachments.Add FullName -> If you want to add attachments
.Body = "Hi there" & vbNewLine & vbNewLine & "How are you " & Cells(r, 2)
.Display 'Or use Send
End With
Next r
Set OutMail = Nothing
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub