|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub sendmail()
On Error Resume Next
Dim rowCount, endRowNo
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Dim arr, n
endRowNo = Cells(1, 1).CurrentRegion.Rows.Count
Set objOutlook = New Outlook.Application
For rowCount = 2 To endRowNo
Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = Cells(rowCount, 3).Value '邮件的地址
.CC = Cells(rowCount, 4).Value '邮件的抄送地址
.Subject = Cells(rowCount, 1).Value '"邮件主题"
.Body = Cells(rowCount, 2).Value '"邮件内容"
arr = Split(Cells(rowCount, 5).Value, ";")
For n = LBound(arr) To UBound(arr)
.Attachments.Add (arr(n)) '邮件的附件
Next
.Send
End With
Set objMail = Nothing
Next
Set objOutlook = Nothing
MsgBox "共发送了 " & rowCount - 2 & " 封邮件。", vbInformation
End Sub
如何操作可以将B列的格式应用于Outlook邮件正文,谢谢!
|
|