代码之家  ›  专栏  ›  技术社区  ›  Casey M

发送前保存当前附件的副本

  •  1
  • Casey M  · 技术社区  · 7 年前

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

    任何帮助都会很好!非常感谢。

        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
    
    1 回复  |  直到 4 年前
        1
  •  1
  •   0m3r    7 年前

    简单使用 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