|
楼主 |
发表于 2014-9-11 16:58
|
显示全部楼层
下面的这段代码可以实现,自由添加邮件地址,自由修改主题,自由添加附件,但是正文搞不了,只能改称呼。
Sub sendemail()
Dim myOlApp As Object
Dim myitem As Object
Dim i As Integer, j As Integer
Dim strg As String
Dim atts As Object
Dim mycc As Object
Dim myfile As String
Set myOlApp = CreateObject("Outlook.Application")
With Sheets("Sheet1")
i = 2
Do While .Cells(i, 2) <> ""
Set myitem = myOlApp.CreateItem(0)
Set atts = myitem.Attachments
myitem.To = .Cells(i, 2) '收件人E-mail
myitem.Subject = .Cells(i, 3) '标题
myitem.Body = "尊敬的" & Cells(i, 1) & "店铺负责人," & vbNewLine & vbNewLine & vbNewLine & .Cells(i, 4) '正文
myfile = Dir(ThisWorkbook.Path & "\*" & .Cells(i, 1) & "*.*")
Do Until myfile = ""
myitem.Attachments.Add ThisWorkbook.Path & "\" & myfile, 1
myfile = Dir
Loop
myitem.display '预览,如果想直接发送,把.display改为.send
i = i + 1
strg = ""
Loop
End With
Set myitem = Nothing
End Sub
|
|