|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
各位大神,附件中工作簿“111”中的宏做出来的效果只能是一个邮件带一个附加,如果我想要第三个收件人“liweifang”的邮件附带“TS2”,“TS3”两个附件,代码和表“发送”需要怎么修改吗?
昨天苦想无果后,特向各位请教,谢谢!
原代码如下:
- Sub displayemail()
- 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("发送名单")
- i = 2
- Do While .Cells(i, 2) <> ""
- Set myitem = myOlApp.CreateItem(0)
- Set atts = myitem.Attachments
- myitem.To = .Cells(i, 3) '收件人E-mail
- myitem.cc = .Cells(i, 4) 'Cc
- myitem.Subject = .Cells(i, 5) '标题
- myitem.Body = "Dear:" & vbNewLine & "#REF!单元格数据为空!" '正文
- myfile = Dir(ThisWorkbook.Path & "\*" & .Cells(i, 1) & "*.*") '上传附件
- Do Until myfile = ""
- myitem.Attachments.Add ThisWorkbook.Path & "" & myfile, 1
- myfile = Dir
- Loop
- myitem.send '预览,如果想直接发送,把.display改为.send
- i = i + 1
- strg = ""
- Loop
- End With
- Set myitem = Nothing
- End Sub
复制代码
|
|