OUTLOOK vba过滤器,带有like语句

时间:2018-08-28 14:31:45

标签: vba outlook outlook-vba

我想发表一个喜欢的声明,因为我想过滤以tmeadmin@开头的电子邮件

此代码在like语句的行上中断。我如何解决它?

 Dim objOutlook As Outlook.Application
    Dim objNamespace As Outlook.NameSpace
    Dim objSourceFolder As Outlook.MAPIFolder
    Dim objDestFolder As Outlook.MAPIFolder
    Dim InboxMsg As Object
    Dim Inbox As Outlook.Folder
    Set objOutlook = Application
    Set objNamespace = objOutlook.GetNamespace("MAPI")
    Set Inbox = objNamespace.GetDefaultFolder(olFolderInbox)
    Dim myRestrictItems As Outlook.Items
     Dim filter As String
     filter = "urn:schemas:httpmail:fromemail LIKE 'tmeadmin@%'"

      MsgBox (filter)
 Set myRestrictItems = Inbox.Items.Restrict(filter)

1 个答案:

答案 0 :(得分:0)

要使用LIKE运算符,您需要使用@SQL语法:

filter = "@SQL=urn:schemas:httpmail:fromemail LIKE 'tmeadmin@%'"