指定某个类别后,将电子邮件移动到指定的文件夹 [英] Move emails to specified folder after assigning certain category
问题描述
您好我是VBA上的新手,我希望有一个代码可以自动移动电子邮件以匹配文件夹或子文件夹已经
创建一旦我分配了一个类别,并在我删除该类别后立即删除它例如:
我有文件夹以这种方式组织:
1.Inbox
- 1.2。什么
------ 1.2.1。发票
------ 1.2.3。预算
- 1.3。当
------ 10月1.3.1
------ 9月1。2日
- 1.4。其中
------ 1.4.1。里斯本
- 1.5。谁
------ 1.5.1。约翰
------ 1.5.2.Stewart
------ 1.5.3.William
如果我分配了类别"John"和"Budget",则邮件将被移动到文件夹1.2.3。预算和1.5.1.John,
以及如果我设置为no消息类别将返回收件箱。 这可能吗?!
干杯
嗨CoNN3CT3D,
根据您的要求,我建议您将其拆分为多个部分,第一部分是将邮件从收件箱移动到子文件夹。
您可以尝试以下代码:
Private WithEvents Items As Outlook.Items
Private WithEvents objItem As Outlook.MailItem
Private WithEvents objFolder As Outlook.Folder
Private Sub Application_Startup()
Dim olApp作为Outlook.Application
Dim objNS As Outlook.NameSpace
设置olApp = Outlook.Application
设置objNS = olApp.GetNamespace(" MAPI")
'默认本地收件箱
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemChange(ByVal Item As Object)
Dim prompt As String
Dim olApp作为Outlook.Application
设置olApp = Outlook.Application
设置objNS = olApp.GetN amespace(" MAPI")
prompt = Item.Categories
如果是InStr(提示,"John")> 0然后
Item.Move objNS.GetDefaultFolder(olFolderInbox).Folders(" 1.2.What")。Folders(" 1.2.3.Budgets")
End if
结束子
最好的问候,
Edward
Hello im new on VBA, and I would like to have a code that would automatically move emails to match folders or subfolders already
created once I assigned a category, and be removed from it as soon as I removed the category, for example:
I have the folders organized this way:
1.Inbox
--1.2. What
------1.2.1. Invoice
------1.2.3. Budget
--1.3. When
------1.3.1 October
------1.3.2 September
--1.4. Where
------1.4.1. Lisbon
--1.5. Who
------1.5.1. John
------1.5.2. Stewart
------1.5.3. William
If I assigned the category "John" and "Budget", the message is moved to folder 1.2.3. Budgets and 1.5.1. John,
and if i set no category the message will return to inbox. Is this possible?!
Cheers
Hi CoNN3CT3D,
For your requirement, I would suggest you split it into many parts, and the first part would be move mail from inbox to subfolders.
You could try code below:
Private WithEvents Items As Outlook.Items Private WithEvents objItem As Outlook.MailItem Private WithEvents objFolder As Outlook.Folder Private Sub Application_Startup() Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Set olApp = Outlook.Application Set objNS = olApp.GetNamespace("MAPI") ' default local Inbox Set Items = objNS.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemChange(ByVal Item As Object) Dim prompt As String Dim olApp As Outlook.Application Set olApp = Outlook.Application Set objNS = olApp.GetNamespace("MAPI") prompt = Item.Categories If InStr(prompt, "John") > 0 Then Item.Move objNS.GetDefaultFolder(olFolderInbox).Folders("1.2.What").Folders("1.2.3.Budgets") End If End SubBest Regards,
Edward
这篇关于指定某个类别后,将电子邮件移动到指定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!