VBA / Rule更改传入电子邮件的主题行,然后移至文件夹

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

我想编写一个脚本,将接收特定的传入电子邮件,更改其主题行,然后将该电子邮件移至特定的文件夹。

我可以找到在邮件本身打开时会更改主题行的脚本,但是当与“移至文件夹”规则绑定时,主题不会更改。

我已经尝试过此代码,该代码可以在我打开的邮件的主题行中添加文本。

Sub myRuleMacro(Item As Outlook.MailItem)

Sub AddToEndOfSubjectLine()
If ActiveInspector Is Nothing Then Exit Sub
ActiveInspector.CurrentItem.Save
ActiveInspector.CurrentItem.subject = ActiveInspector.CurrentItem.subject & " HELLO!"
End Sub

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

End Sub
vba outlook outlook-vba rules
1个回答
0
投票

这里是一个例子,尝试一下

Public Sub Example(Item As Outlook.MailItem)
    Dim SubFolder As Outlook.folder
    Set SubFolder = Application.GetNamespace("MAPI").GetDefaultFolder _
                         (olFolderInbox).Folders("folder name here") '<- change folder name

    Debug.Print Item.Subject ' Print on Immediate Window

    Item.Subject = Item.Subject & " HELLO!"
        Item.Save
        Item.Move SubFolder

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