«Подобный макрос в Outlook 2007 создаст некоторые правила, совместимые с надстройкой« Импорт / экспорт »фильтра сообщений Thunderbird. Замените имена пользователей и домены своими адресами электронной почты и доменами сервера.
Option Explicit
Sub CreateRule()
Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim j As Integer
Dim email(5) As String
Dim server(5) As String
'Get Rules from Session.DefaultStore object
Set colRules = Application.Session.DefaultStore.GetRules()
email(1) = "username1%40domain1.com"
email(2) = "username2%40gmail.com"
email(3) = "username3%40gmail.com"
email(4) = "username4%40domain2.com-"
email(5) = "username4%40gmail.com"
server(1) = "mail.domain1.com"
server(2) = "imap.googlemail.com"
server(3) = "imap.googlemail.com"
server(4) = "imap.domain2.com"
server(5) = "imap.googlemail.com"
For j = 1 To 5
Open "c:\temp\" + email(j) + ".txt" For Output As #1
Print #1, "RootFolderUri=mailbox://" + email(j) + "@" + server(j)
Print #1, "mailnews.customHeaders="
Print #1, "version=""9"""
Print #1, "logging=""no"""
Dim i As Integer
For i = 1 To colRules.Count
Set oRule = colRules.item(i)
' break here, right click, add watch to see the structure of oRule
If Len(oRule.Name) > 0 And oRule.Enabled And oRule.conditions.from.Enabled And oRule.conditions.from.recipients.Count > 0 And oRule.actions.MoveToFolder.Enabled Then
Print #1, "name=""From is: " + oRule.Name + """"
Print #1, "enabled=""yes"""
Print #1, "type=""16""" ' type 16 for manually run only, type 17 for manually run and run on checking mail
Print #1, "action=""Move to folder"""
Print #1, "actionValue=""mailbox://nobody@Local%20Folders/Outlook%20Import/Personal%20Folders/Inbox/" + oRule.actions.MoveToFolder.folder + """"
Print #1, "condition=""AND (from,is," + oRule.conditions.from.recipients.item(1).Address + ")"""
End If
Next i
Close 1
Next j
End Sub