将文件名添加到电子邮件主题行并将电子邮件发送到上次修改者/作者

问题描述 投票:1回答:2

我有一个Word文档,在其中放置了CommandButton在文档上,以便用户可以发送带有消息的Outlook电子邮件,但是我希望电子邮件的主题是打开的活动Word文档的名称,因此,根据活动文档的名称和发送给该活动文档Wd的作者的电子邮件,主题是可变的。

要标识姓氏/作者的最后修改者,并根据该名字将其转换为[email protected]?作者将向他的上级发送一封电子邮件,并且该人员将通过CommandButton对该文档进行审核。

Public Sub Mail()
    Dim LastAuthor As String
        LastAuthor = ActiveDocument.BuiltInDocumentProperties("last Author")

        Dim Email As String
            Email = Replace(LastAuthor, " ", ".") & "@btrl.ro"


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .Display
        .Signature = "HTMLbody"
        .To = Email
        .CC = ""
        .BCC = ""
        .Subject = ActiveDocument.Name
        '.Body = "AVIZAT. Multumesc mult"
        '.Attachments.Add ActiveDocument.FullName
        ' You can add other files by uncommenting the following line.
        '.Attachments.Add ("C:\test.txt")
        ' In place of the following statement, you can use ".Display" to
        ' display the mail.
        .HTMLbody = "AVIZAT" & "<br>" & .HTMLbody

        Dim objDoc As Document
        Set objDoc = ActiveDocument
        objDoc.ExportAsFixedFormat _
        OutputFileName:=Replace(objDoc.FullName, ".docx", ".pdf"), _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
        Range:=wdExportAllDocument, Item:=wdExportDocumentContent
        ' Add the attachment first for correct attachment's name with non English symbols
        .Attachments.Add PdfFile.FullName

        .send
        MsgBox "E-mail trimis cu succes"

    Set OutMail = Nothing
    Set OutApp = Nothing

    End With

End Sub
vba outlook ms-word
2个回答
-1
投票

应该。


0
投票

用途:

© www.soinside.com 2019 - 2024. All rights reserved.