规则/宏重命名pdf文件并重新发送给不同的收件人?

时间:2016-10-04 18:04:20

标签: vba outlook outlook-vba

如何重命名与主题行相同的 pdf 附件,然后将重命名的文件通过电子邮件发送给其他收件人。

例如,我收到的电子邮件的主题行为 "123456-CHM78912" ,但附件 pdf 名称将为 { {1}} 即可。

"INV-5"

1 个答案:

答案 0 :(得分:0)

设置Outlook规则并调用以下脚本

Option Explicit
Public Sub SaveAtmts(Item As Outlook.MailItem)
    Dim Atmt As Outlook.Attachment
    Dim Path As String
    Dim SaveAtmt As String
    Dim AtmtName As String

    Path = "C:\Temp\"
    AtmtName = Item.Subject & ".pdf"

    For Each Atmt In Item.Attachments
        If Right(Atmt.FileName, 3) = "pdf" Then
            SaveAtmt = Path & AtmtName
            Atmt.SaveAsFile SaveAtmt
        End If
    Next

'   // Email the file
    Set Item = Application.CreateItem(olMailItem)

    With Item
        .Subject = "Subject"
        .body = AtmtName & " Report Attached "
        .To = "0m3r@Email.com"
        .Attachments.Add SaveAtmt
'        // Display msg
'        .Display
'        ' Or Send
        .Send
    End With
End Sub