Outlook 更改邮件类别

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

有没有办法更改消息类,以便我可以在 VBA 中获得 READ 消息的专门视图? C# 插件可以做到吗? 并在发送时重置为基本的“IPM.Note”?

我想添加文件夹路径,以便当我阅读邮件时我可以看到该文件夹(并最终单击跳转到那里)。我尝试了 ThisOUtlookSession 对象检查器和 WithEvents 来尝试在打开之前进行设置和保存,但它使用默认的 IPM。

Option Explicit
Const otlIPMcustFormClass As String = "IPM.Note.CustomReadForm" ' Custom form class for reading

Sub UpdateSelectedMailForm()
    Dim objSelection As Outlook.Selection
    Dim mailItem As Outlook.mailItem
    Dim i As Integer

    ' Get the currently selected items in the explorer
    Set objSelection = Application.ActiveExplorer.Selection

    ' Loop through each selected item
    For i = 1 To objSelection.Count
        ' Check if the selected item is a MailItem
        If TypeOf objSelection.Item(i) Is Outlook.mailItem Then
            Set mailItem = objSelection.Item(i)
            
            ' Update the MessageClass to the custom form class
            mailItem.MessageClass = otlIPMcustFormClass ' Use your custom form class constant
            
            ' Save the changes
            mailItem.Save
            mailItem.Display

            ' Optional: Display a message or log the update
            ''MsgBox "Updated the form for: " & mailItem.subject, vbInformation
        Else
            ' If it's not a mail item, notify the user
            MsgBox "Selected item is not a MailItem. Please select an email.", vbExclamation
        End If
    Next i
End Sub
vba outlook
1个回答
0
投票

出于性能原因,Outlook 喜欢缓存其项目。没有办法控制它的缓存。作为一般经验法则,取消引用一个项目,打开另一个项目,然后打开第一个项目就足够了。重新启动 Outlook 肯定会起作用。

但是你为什么要即时执行此操作呢?为什么需要更改项目类别?如果您想显示额外的提示/按钮,功能区控件或任务窗格/表单区域会做得更好

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.