根据过滤表范围内的文件路径向Outlook电子邮件添加附件



我想将过滤表中列出的文件作为附件添加到Outlook电子邮件正文中。

代码创建了一个电子邮件,并将table2添加到正文中。

如果我过滤表,它将复制表中过滤的部分(我想要的)。

我希望在过滤表中列出的文件也作为附件添加。

例如,我在列"G"中有文件路径,假设从G2到G10,并且我过滤我的表以显示G3, G4和G5,我希望在这些单元格中列出的文件作为附件添加到Outlook电子邮件中。

无论我如何过滤表,下面一行只添加单元格G2上列出的文件:

.attachments.Add "C:RemoteAMBAbinSoftTokens" & Range("g2").Value

完整代码:

Sub Soft_Token_Distribution()
Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object
Dim path As String
Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)
With newEmail
.To = Sheet4.Range("L2").Text
.CC = ""
.BCC = ""
.Subject = "ADD SUBJECT LINE HERE"
.HTMLBody = "Hi, <br/><br/> As part of your <b> Create, Modify or Terminate SOW Contingent Worker </b> ServiceNow request for the below user, you requested Remote Access for the user. <br/><br/> Vendor Remote Access has been provisioned for this user. Please share the attached documents with the user so that they can configure their Vendor Remote Access. <br/><br/> Regards,"

.attachments.Add "C:RemoteAMBAbinSoftTokens" & Range("g2").Value

Set .SendUsingAccount = outlook.Session.Accounts.Item(2)

.Display
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor

Sheet4.Range("Table2[#All]").Copy

pageEditor.Application.Selection.Start = 316
pageEditor.Application.Selection.End = 
pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)

.Display
'.Send
Set pageEditor = Nothing
Set xInspect = Nothing
End With
Set newEmail = Nothing
Set outlook = Nothing
End Sub

您需要遍历所讨论的调用,并为每个单元格调用newEmail.Attachments.Add

相关内容

  • 没有找到相关文章

最新更新