基于该行VBA中的单元格值的电子邮件行

时间:2016-01-06 18:43:12

标签: excel excel-vba html-email vba

我有一张excel表,我需要向范围C中提到的所有人发送电子邮件。我想复制整行并将其发送到该单元格中提到的电子邮件ID。如果C1到C5中有相同的电子邮件ID,则应将整行从A1复制到Z5。有人可以帮忙吗

Sub try()
Dim del As String
del = 2
Do
 Dim OutApp As Object
Dim OutMail As Object
Dim emlBody, sendTo As String
Dim wkbook As String
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

'Set OutApp = CreateObject("Outlook.Application")
'Set OutMail = OutApp.CreateItem(0)

With OutMail
sendTo = Range("C" & del)
emlBody = Range("D" & del)
    .SentOnBehalfOfName = "abc@abc.com"
    .To = sendTo
    '.HTMLBody =
    .Subject = Range("B" & del)
    .Display
    del = del + 1
    End With
    Loop Until Range("A" & del) = ""
   MsgBox ("All Mails have been Successfully Updated and it is ready to be Sent.")

  End Sub

0 个答案:

没有答案