【问题标题】:Download embedded pictures-images and attachments from Outlook using Powershell使用 Powershell 从 Outlook 下载嵌入的图片图像和附件
【发布时间】:2014-01-07 07:05:48
【问题描述】:

我使用 Windows 7 64 位、Outlook 2010,并且我正在寻找一个 powershell 脚本来从 Outlook 电子邮件中下载嵌入的图片和附件。

目前唯一的选择是打开每条消息并复制每张图片。电子邮件目前在 Outlook 中,但如果需要,我可以将它们保存到文件夹中。

有人能指出正确的方向吗?

【问题讨论】:

    标签: powershell automation outlook-2010


    【解决方案1】:

    我编写了这个小脚本来将附件保存到文件夹中。在 Windows 8.1 x64 上使用 Outlook 2010 进行测试。

    $o = New-Object -ComObject outlook.Application
    $ns = $o.GetNamespace("MAPI")
    $f = $ns.Folders.Item(1)
    $di = $f.Folders.item("Deleted Items")
    $messagesWithAttachments = $di.items | Where-Object {$_.Attachments.Count -gt 0}
    $messagesWithAttachments[0].Attachments.item(1).saveasfile("X:\test\picture.jpg")
    

    如果您想保存所有附件,只需遍历邮件、附件并为文件指定唯一名称即可。为此,您可以使用 System.IO.Path.GetRandomFileName 之类的东西。如果文件名已经存在,则获取一个新的。

    【讨论】:

    • 太棒了。也许对于消息中的嵌入图像是可能的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 2015-12-20
    • 1970-01-01
    • 2021-03-06
    • 2020-11-30
    • 1970-01-01
    相关资源
    最近更新 更多