|
各位好:
如何让全部收件人正文 调用当前文件夹“邮件正文.doc”里面的内容!
- 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) 'TO 收件人E-mail
- myitem.cc = .Cells(i, 3) 'CC
- myitem.Subject = .Cells(i, 4) '标题
- myitem.Body = .Cells(i, 5) & ",你好!" & vbNewLine & vbNewLine & vbNewLine & .Cells(i, 6) '正文
- 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
复制代码
|
|