我想根据这种情况向多个收件人发送邮件:
Sheet1包含不同的记录(按行)
不同记录可能有相同的收件人。必须将整个Sheet1发送给收件人。
Sheet2包含
基于Sheet1和所有用户的首字母,我想发送到Sheet2上找到的地址。这是我正在努力的部分。
以下是我的代码的一部分:
Sub test_mail()
Dim OutApp As Object
Dim OutMail As Object
Dim emailRng As Range, cl As Range
Dim sTo As String
Set emailRng = Worksheets("Sheet2").Range("B1:B6") // not dynamic at all because will be changed each time..
For Each cl In emailRng
sTo = sTo & ";" & cl.Value
Next
sTo = Mid(sTo, 2)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = sTo
.CC = "person1@email.com;person2@email.com"
.BCC = ""
.Subject = "SS failed to load
.Body = "Dear user,"
.Attachment = // How to put directly sheet 1 ??
.Display
End With
我正在考虑删除Sheet1的H列中的重复项以获取列表并将其与v-look相关联以从Sheet2获取电子邮件地址。但我确信这是一种更简单的方法。