使用RegEx将传入电子邮件移动到文件夹中 [英] Move incoming email to folders with RegEx in a rule
本文介绍了使用RegEx将传入电子邮件移动到文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用正则表达式通过查看主题行来过滤传入的消息,如果它包含6个连续的数字,请将其移至特定的文件夹.
I am trying to use a regular expression to filter incoming messages by looking at the subject line and if it contains 6 consecutive digits, move it to a particular folder.
我在网上找到了一个一直在尝试修改的脚本.
I found a script online which I have been trying to modify.
我想将这些电子邮件放在名为"AMEX
"的文件夹中,该文件夹是主收件箱的subfolder
.
I want to place these emails in a folder called 'AMEX
' which is a subfolder
of the main Inbox.
Sub filter(Item As Outlook.MailItem)
Dim ns As Outlook.NameSpace
Dim MailDest As Outlook.Folder
Set ns = Application.GetNamespace("MAPI")
Set Reg1 = CreateObject("VBScript.RegExp")
Reg1.Global = True
Reg1.Pattern = "([\d][\d][\d][\d][\d][\d])"
If Reg1.Test(Item.Subject) Then
Set MailDest = ns.Folders("Inbox").Folders("AMEX")
Item.Move MailDest
End If
End Sub
推荐答案
您的问题出在文件夹名称上 替换Set MailDest = ns.Folders("Inbox").Folders("AMEX")
your problem is with the folder name replace Set MailDest = ns.Folders("Inbox").Folders("AMEX")
与此行
Set MailDest = ns.Folders("enteryouraccountname@yourhost.com").Folders("Inbox").Folders("AMEX")
别忘了输入您的帐户名
这篇关于使用RegEx将传入电子邮件移动到文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文