【问题标题】:Is there any way to add a specific category and flag an email in VBA?有没有办法在 VBA 中添加特定类别并标记电子邮件?
【发布时间】:2009-11-14 14:36:55
【问题描述】:

我通常会浏览我的电子邮件并标记任何内容以进行跟进和分类:

  1. 电话
  2. 电子邮件
  3. 交谈
  4. 设置会议

在 Outlook VBA 宏中是否有任何方法,我可以(在单个宏中)标记要关注的项目并在其上设置上述类别之一?

【问题讨论】:

  • 您能否添加您正在使用的 Outlook 版本。对象模型在 2003 年和 2007 年之间发生了显着变化
  • 是的,这很容易做到。您是否正在寻找一个按钮,加上一个下拉菜单,设置为调用宏。
  • dailydoseofexcel.com/archives/2007/03/19/outlook-tags 你可能会发现这篇文章的 cmets 很有用。

标签: vba outlook-2007


【解决方案1】:

我找到了答案。 。下面列出 。 . .

Private Sub TagArchived1(category As String)

    Dim objOutlook As Outlook.Application
    Dim objInspector As Outlook.Inspector

    Dim strDateTime As String

    ' Instantiate an Outlook Application object.
    Set objOutlook = CreateObject("Outlook.Application")

    ' The ActiveInspector is the currently open item.
    Set objExplorer = objOutlook.ActiveExplorer

    ' Check and see if anything is open.
    If Not objExplorer Is Nothing Then
        ' Get the current item.
        Dim arySelection As Object
        Set arySelection = objExplorer.Selection

        For x = 1 To arySelection.Count
            Dim m As MailItem
            Set m = arySelection.Item(x)
            m.Categories = category
            m.FlagStatus = olFlagMarked
            m.FlagIcon = 6
            m.Save
        Next x

    Else
        ' Show error message with only the OK button.
        MsgBox "No explorer is open", vbOKOnly
    End If

    ' Set all objects equal to Nothing to destroy them and
    ' release the memory and resources they take.
    Set objOutlook = Nothing
    Set objExplorer = Nothing
End Sub

【讨论】:

    猜你喜欢
    • 2021-01-01
    • 1970-01-01
    • 2010-10-09
    • 1970-01-01
    • 2020-02-12
    • 2021-12-29
    • 2016-08-17
    • 1970-01-01
    • 2013-10-19
    相关资源
    最近更新 更多