且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Outlook VBA将多个附件添加到单个电子邮件中

更新时间:2021-07-13 07:38:34

您只需要这样做:

 Olmail.attachments.add secondpath

如果将附件路径放在逗号分隔的字符串中,并将其作为"FilePathToAdd"传递,则可以执行以下操作:

If you put the attachment paths in a comma delimited string and pass it as "FilePathToAdd" then you can do this:

Dim Attachments() As String
Dim i As Integer

If FilePathToAdd <> "" Then
    Attachments = Split(FilePathToAdd, ",")
    For i = LBound(Attachments) To UBound(Attachments)
        If Attachments(i) <> "" Then
            OlMail.Attachments.Add Trim(Attachments(i))
        End If
    Next i
End If