发送带有多个附件的电子邮件
我正在使用以下代码发送电子邮件。
我想阅读多个查找附件的单元格。
For i = 2 To n
Set msg = outlook.createitem(0)
msg.SentOnBehalfOfName = sheet.Range("F" & i).Value
msg.To = sheet.Range("G" & i).Value
msg.cc = sheet.Range("H" & i).Value
msg.Subject = sheet.Range("I" & i).Value
msg.body = sheet.Range("J" & i).Value
If sheet.Range("K", i).Value <> "" Then
msg.attachments.Add sheet.Range("K" & i).Value
msg.Show
Next i
它适用于任何类型的附件。
如何将其修改为多个文件?
我尝试了一个嵌套的循环,但找不到任何结果。
I am using the following code to send emails.
I want to read more than one cell for finding attachments.
For i = 2 To n
Set msg = outlook.createitem(0)
msg.SentOnBehalfOfName = sheet.Range("F" & i).Value
msg.To = sheet.Range("G" & i).Value
msg.cc = sheet.Range("H" & i).Value
msg.Subject = sheet.Range("I" & i).Value
msg.body = sheet.Range("J" & i).Value
If sheet.Range("K", i).Value <> "" Then
msg.attachments.Add sheet.Range("K" & i).Value
msg.Show
Next i
It does work for a single attachment of any kind.t
How do I modify it for more than one file?
I tried a nested for loop for it but was unable to find any result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果下一列包含一个附件路径,则可以添加另一个条件,如果要在此处指定的文件附加。
因此,您可以将其进一步推断到工作表上的其他列。
If the next column contains an attachment path you can add yet another if condition to attach the file specified there.
So, you can further extrapolate this to other columns on the sheet.