【问题标题】:How to take different actions depending on folder of Outlook item?如何根据 Outlook 项目的文件夹采取不同的操作?
【发布时间】:2021-03-17 21:44:05
【问题描述】:

我想标记和标记项目以采取行动。

如果该项目位于任何收件箱或常规邮件文件夹中,请标记该项目,将其标记为“#Action”并将其移至“#Action”文件夹。

如果该项目位于已发送文件夹中,请标记该项目并将其移动到“#Inquiry”文件夹。

如何在采取行动之前检查项目所在的文件夹?

我想我可以先这样声明发送的文件夹:

Dim SentItems As Folder  
Set SentItems = Outlook.Application.GetNamespace("MAPI")>GetDefaultFolder(olFolderSentMail)

如何检查某个项目是否在 SentItems 中?

类似

Dim obj As Object Dim msg As Outlook.MailItem
For Each obj In ActiveExplorer.Selection

    If obj In SentItems Then
        do the sent item stuff
    Else
        do the all other folder stuff
    End If

【问题讨论】:

  • 您的代码如何获取/接收项目 obj ?来自用户的选择?
  • Dim obj As Object Dim msg As Outlook.MailItem For Each obj In ActiveExplorer.Selection

标签: vba outlook-2016


【解决方案1】:

你可以使用

obj.Parent.Name

或许

obj.Parent.FullFolderPath

【讨论】:

    【解决方案2】:
    If obj.Parent.Name = "Sent Items" Then 
    stuff 
    Else
    other stuff 
    End If
    

    【讨论】:

      猜你喜欢
      • 2015-03-02
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多