Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 1259
Благодарности: 861

Профиль | Отправить PM | Цитировать


"_ФЗ-223" - где располагается данная папка?

И скрипт содержит ошибки и отсутсвуют команды.

Код: Выделить весь код
$oOutlook    = New-Object -ComObject Outlook.Application
$olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$olRuleType = "Microsoft.Office.Interop.Outlook.OlRuleType" -as [type]
Write-Verbose "Получение папки входящие"
$oNameSpace  = $oOutlook.GetNamespace("MAPI")
$inbox = $oNameSpace.getDefaultFolder($olFolders::olFolderInbox)


$RuleName = "ФЗ-223_rule"
$RedirectFolder = "_ФЗ-223"
$FromEmail = "fz223@domen.ru"
	
$rules = $outlook.session.DefaultStore.GetRules()
$rule = $rules.Create($RuleName,$olRuleType::OlRuleReceive)

$d = [System.__ComObject].InvokeMember(
       "EntryID",
       [System.Reflection.BindingFlags]::GetProperty,
        $null,
        $inbox.Folders.Item($RedirectFolder),
        $null
)
    
$MoveTarget = $namespace.getFolderFromID($d)
$MoveRuleAction = $rule.Actions.MoveToFolder

[Microsoft.Office.Interop.Outlook._MoveOrCopyRuleAction].InvokeMember(
        "Folder",
        [System.Reflection.BindingFlags]::SetProperty,
        $null,
        $MoveRuleAction,
        $MoveTarget)
$MoveRuleAction.Enabled = $true

$FromCondition = $rule.Conditions.From
$FromCondition.Enabled = $true
$FromCondition.Recipients.Add($FromEmail)
$fromCondition.Recipients.ResolveAll()

$rules.Save()

Отправлено: 10:42, 04-06-2015 | #4