AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1524047
Accepted
leeand00
leeand00
Asked: 2020-02-10 11:24:08 +0800 CST2020-02-10 11:24:08 +0800 CST 2020-02-10 11:24:08 +0800 CST

什么 powershell 模块可用于驯服您的收件箱?

  • 772

我厌倦了尝试使用 Outlook 的 GUI 创建/删除/管理收件箱规则;这需要很长时间,而且很糟糕。

我了解 powershell 中有 cmdlet 允许您在服务器端和客户端执行此操作。

我无法访问服务器端,我只对使用这些规则管理我自己的收件箱感兴趣。

以下文章似乎提到了一些对此非常有用的 cmdlet,但我无法使用它们,因为我不知道从哪里导入库:

https://www.codetwo.com/admins-blog/managing-outlook-rules-powershell/

如何首先安装 cmdlet?我在哪里可以获得它们,我需要用什么将它们导入到脚本中?

microsoft-outlook email
  • 2 2 个回答
  • 2212 Views

2 个回答

  • Voted
  1. Best Answer
    postanote
    2020-02-10T23:13:38+08:002020-02-10T23:13:38+08:00

    将其放在这里是因为该评论部分太长了。

    驯服您的邮箱是一个问题,您是在独立客户端(胖客户端、云客户端或两者兼有 - 请记住您可以直接在 Outlook 胖客户端中添加 Outlook.com 帐户)或您企业中的用户谈论您。 .

    您不使用 Exchange cmdlet 来控制本地 Outlook。要使用 Exchange cmdlet,您必须在您的计算机上安装 Exchange 命令行管理程序...

    安装 Exchange 管理工具

    ...或使用 PowerShell 隐式远程处理将这些 cmdlet 代理到您的主机。隐式远程处理也是您将 Exchange cmdlet 用于 O365 的方式。这些是 Microsoft 的详细记录/详细信息,以及遍布网络和 Youtube 视频的大量博客。

    连接到 Office 365 PowerShell

    在单个 Windows PowerShell 窗口中连接到所有 Office 365 服务

    连接到所有 Office 365 服务 PowerShell(也支持 MFA)

    甚至为此工作的预建模块。

    连接-O365 1.7.9

    使用 PowerShell 连接到 Office 365 服务

    带有帮助函数的 PowerShell 脚本,用于连接到 Office 365 或 Exchange On-Premises。使用相同的凭据(非 MFA)可以轻松连接到不同的 Office 365 服务。不再需要记住连接到每个工作负载的各种方式。

    从 Exchange 命令行管理程序(使用 PowerShell)管理用户的 Outlook 规则

    Youtube - Powershell O365

    Outlook Online 有一个 Rest API 可以与 Exchange、EWS 一样使用

    Office 365 管理 API 概述

    Outlook 客户端

    优酷-

    Outlook REST API 为任何 Office 365 或 Outlook.com 用户提供了访问邮件、日历和联系人数据的简便方法。在本视频中,我们将介绍 API V2.0 中引入的一些关键功能:Webhooks、照片、提醒和时区。

    使用 PowerShell 对 Outlook 收件箱进行数据挖掘

    # Get-OutlookInBox function
    Function Get-OutlookInBox
    {
      <#
    
       .Synopsis
        This function returns InBox items from default Outlook profile
    
       .Description
        This function returns InBox items from default Outlook profile. It
        uses the Outlook interop assembly to use the olFolderInBox enumeration.
    
        It creates a custom object consisting of Subject, ReceivedTime, Importance,
        SenderName for each InBox item.
    
        *** Important *** depending on the size of your InBox items this function
        may take several minutes to gather your InBox items. If you anticipate
        doing multiple analysis of the data, you should consider storing the
        results into a variable, and using that.
    
       .Example
        Get-OutlookInbox |
        where { $_.ReceivedTime -gt [datetime]”5/5/11″ -AND $_.ReceivedTime -lt `
    
        [datetime]”5/10/11″ } | sort importance
    
        Displays Subject, ReceivedTime, Importance, SenderName for all InBox items that
        are in InBox between 5/5/11 and 5/10/11 and sorts by importance of the email.
    
       .Example
        Get-OutlookInbox | Group-Object -Property SenderName | sort-Object Count
    
        Displays Count, SenderName and grouping information for all InBox items. The most
        frequently used contacts appear at bottom of list.
    
       .Example
        $InBox = Get-OutlookInbox
    
        Stores Outlook InBox items into the $InBox variable for further
        “offline” processing.
    
       .Example
        ($InBox | Measure-Object).count
    
        Displays the number of messages in InBox Items
    
       .Example
        $InBox | where { $_.subject -match ‘2011 Scripting Games’ } |
        sort ReceivedTime -Descending | select subject, ReceivedTime -last 5
        Uses $InBox variable (previously created) and searches subject field
        for the string ‘2011 Scripting Games’ it then sorts by the date InBox.
        This sort is descending which puts the oldest messages at bottom of list.
        The Select-Object cmdlet is then used to choose only the subject and ReceivedTime
        properties and then only the last five messages are displayed. These last
        five messages are the five oldest messages that meet the string.
    
       .Notes
        NAME:  Get-OutlookInbox
        AUTHOR: ed wilson, msft
        LASTEDIT: 05/13/2011 08:36:42
        KEYWORDS: Microsoft Outlook, Office
        HSG: HSG-05-26-2011
    
       .Link
         Http://www.ScriptingGuys.com/blog
    
     #Requires -Version 2.0
    
     #>
    
     Add-type -assembly “Microsoft.Office.Interop.Outlook” | out-null
    
     $olFolders = “Microsoft.Office.Interop.Outlook.olDefaultFolders” -as [type]
    
     $outlook = new-object -comobject outlook.application
    
     $namespace = $outlook.GetNameSpace(“MAPI”)
    
     $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
     $folder.items |
    
     Select-Object -Property Subject, ReceivedTime, Importance, SenderName
    
    } #end function Get-OutlookInbox
    

    您必须是 O365 中的管理员才能执行此操作。O365 中的 Outlook 不是 Exchange,就像桌面上的 Outlook 不是 Exchange。您必须使用 Outlook COM(如上所述和以下)在 Outlook 客户端上工作,这不是 Online 的事情。

    PowerShell 检索 Outlook 地址

    如何:使用 Outlook 从 Powershell 发送邮件

    使用 Powershell 操作 Outlook 对象

    • 2
  2. Silbee
    2020-02-10T12:00:42+08:002020-02-10T12:00:42+08:00

    据我所知,没有可用于 Outlook 的标准 powershell 模块,但是您可以使用可以访问Microsoft.Office.Interop.Outlook命名空间的 Outlook API。创建新规则的简短示例如下:

    首先我们得到命名空间:

    Add-Type -assembly "Microsoft.Office.Interop.Outlook"
    $Outlook = New-Object -comobject Outlook.Application
    $namespace = $Outlook.GetNameSpace("MAPI")
    

    现在我们指定原始文件夹(收件箱),创建一个新规则并指定要复制到的文件夹(通知)

    $inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
    $MyFolder1 =
      $namespace.Folders.Item('[email protected]').Folders.Item('NOTIFICATIONS')
    $rules = $namespace.DefaultStore.GetRules()
    $rule = $rules.create("My rule1: Receiving Notification",
      [Microsoft.Office.Interop.Outlook.OlRuleType]::olRuleReceive)
    
    $rule_body = $rule.Conditions.Subject
    $rule_body.Enabled = $true
    $rule_body.Text = @('Completed Notification')
    $action = $rule.Actions.CopyToFolder
    $action.enabled = $true
      [Microsoft.Office.Interop.Outlook._MoveOrCopyRuleAction].InvokeMember(
        "Folder",
        [System.Reflection.BindingFlags]::SetProperty,
        $null,
        $action,
        $MyFolder1)
    $rules.Save()
    

    您可以在此处找到有关在 powershell 中使用 Outlook 命名空间的更多示例和信息: https ://docs.microsoft.com/en-us/archive/msdn-magazine/2013/march/powershell-managing-an-outlook-mailbox-带powershell

    此外,您可以在此处找到有关 Outlook 对象模型的所有信息: https ://docs.microsoft.com/nl-nl/office/vba/api/overview/Outlook/object-model

    • 1

相关问题

  • SPF 类型 ptr 不鼓励?那我应该用什么?

  • 恢复丢失的 Skype 会议邀请的 Skype 会议 URL

  • 为什么 Thunderbird 不会完全删除电子邮件?

  • 防止保存 PST 文件密码?

  • 主收件箱文件夹中的 Outlook 视图已更改,但其他文件夹未更改

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve