【问题标题】:Save a copy of the current attachment before sending发送前保存当前附件的副本
【发布时间】:2018-01-03 17:10:15
【问题描述】:

在发送备份之前,如何保存我刚刚附加的附件的副本。

任何帮助都会很棒!谢谢。

    Dim outlookOBJ As Object
    Dim MItem As Object

   Set outlookOBJ = CreateObject("Outlook.Application")
   Set MItem = outlookOBJ.CreateItem(olMailItem)
   With MItem
   .To = "email1@gmail.com"
  '.cc = "email2@gmail.com"
   .Subject = " Test Subject"
   .body = " test text in body of email" & Me.EvalID_T1.Value
   .Attachments.Add (ActiveWorkbook.Worksheets("BrowseFile").Cells(4,3).Value)
   'want to add some kind of save current attachment feature here right before I send

    .send

【问题讨论】:

标签: excel vba outlook email-attachments


【解决方案1】:

只需使用For Each … In … Next Loop 保存当前的MItem.Attachments

With MItem
    .To = "email1@gmail.com"
    '.cc = "email2@gmail.com"
    .Subject = " Test Subject"
    .Body = " test text in body of email" & Me.EvalID_T1.value
    .Attachments.Add (ActiveWorkbook.Worksheets("BrowseFile").Cells(4, 3).value)

     Dim Atmt As Object
     For Each Atmt In MItem.Attachments
         Debug.Print Atmt.DisplayName
         Atmt.SaveAsFile "C:\Temp\" & Atmt.DisplayName
     Next

    .Display
End With

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 2015-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多