如何在 Outlook 中转发电子邮件时重命名附件

立即分享:

有时,当您转发包含多个附件的电子邮件时,您可能希望在转发时直接重命名附件。 本文将教您如何使用 Outlook VBA 来完成它。

默认情况下,Outlook 不允许用户在转发时重命名附件。 因此,如果您想重命名它们,唯一的方法是先将文件保存到计算机上的本地文件夹中,然后重命名它们,然后将它们重新附加到转发电子邮件中。 显然这种方法相当麻烦。 此外,有时,这些文件对您来说可能并不重要,所以您真的不想将它们保存到您的计算机中。 在这种情况下,您一定渴望有一种更快捷的方法,让您直接在转发邮件中重命名附件。 下面是一种通过Outlook VBA实现的方法。

转发电子邮件时重命名附件

  1. 首先,启动 Outlook 并前往“开发人员”选项卡。
  2. 然后找到并单击“Visual Basic”按钮。
  3. 之后,在新的弹出窗口中,通过选择“插入”>“模块”打开一个新模块。
  4. 随后,您应该将以下 VBA 代码复制并粘贴到其中。
Sub RenameAttachmentsWhenForwarding()
    Dim olItem As MailItem
    Dim Att As Attachment
    Dim Atts As Attachments
    Dim olForward As MailItem
    Dim FWAtt As Attachment
    Dim FWAtts As Attachments
    Dim FSO As Object
    Dim TempFPath As Object
    Dim FilePath As String
    Dim strName As String
    Dim strExten As String
    Dim strFile As String
 
    Set olItem = Application.ActiveExplorer.Selection.Item(1)
    Set Atts = olItem.Attachments
    Set olForward = olItem.Forward
    olForward.Display
 
    On Error Resume Next
 
    For Each Att In Atts
        'Get the path to Temporary Folder
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set TempFPath = FSO.GetSpecialFolder(2)
        FilePath = TempFPath.Path & "\"
 
        'Rename the attachments
        strName = InputBox("Enter a new name for" & vbCrLf & Att.FileName)
        'Change "4" based on the length of the attachment file extension
        strExten = Right(Att.FileName, 4)
        strFile = FilePath & strName & "." & strExten
 
        If strName <> "" Then
           'Save the attachments to the Temporary Folder
           Att.SaveAsFile (strFile)
 
           'Add the attachments saved in new names from the Temporary Folder
           olForward.Attachments.Add (strFile)
           Set FWAtts = olForward.Attachments
 
           'Remove the original attachments
           For Each FWAtt In FWAtts
               If InStr(FWAtt.FileName, Att.FileName) > 0 Then
                  FWAtt.Delete
               End If
           Next
        End If
    Next
End Sub

VBA 代码 - 转发电子邮件时重命名附件

  1. 之后,您可以退出当前的“Visual Basic”窗口,然后像往常一样继续将新宏添加到快速访问工具栏。将新宏添加到快速访问工具栏
  2. 最后你可以试试看。
  • 首先,选择一封电子邮件,然后单击快速访问工具栏中的新建宏按钮。在 QAT 中选择一个电子邮件并点击按钮
  • 然后将打开一个新的转发电子邮件。 您可以在“附加”行中看到原始名称的附件,还会收到一个对话框,要求您为特定附件输入新名称。在转发电子邮件中为附件输入新名称
  • 为所有文件指定新名称并单击“确定”后,您将看到所有附件都以新名称命名。新名称的附件
  • 最终您可以编写转发电子邮件并点击“发送”按钮将消息发送出去。

对您前景的所有潜在威胁保持警惕

人们认识到 Outlook 容易受到损坏。 因此,保护​​ Outlook 数据免受所有威胁(包括病毒感染、恶意软件攻击和 Outlook PST 数据损坏等。ost 重要的行动是定期备份您的 Outlook 数据。 此外,最好在附近放置顶级维修工具,例如 DataNumen Outlook Repair,这会派上用场。

作者简介:

Shirley Zhang 是一位数据恢复专家 DataNumen, Inc.,它是数据恢复技术领域的世界领先者,包括 修复损坏的中密度纤维板 和 outlook 修复软件产品。 欲了解更多信息,请访问 datanumen.com

立即分享:

评论被关闭。