【发布时间】:2016-10-09 16:48:21
【问题描述】:
我想从 Outlook 中的电子邮件中提取 .xls 文件,将其重命名并将其保存到文件夹中。我找到了一些脚本,但没有一个是根据我的需要完全实现的。
帖子已更新。
我找到了this one,但它没有重命名,是否可以修改此代码以满足我的要求?
#file path
$filepath = “c:\test”
#set outlook to open
$o = New-Object -comobject outlook.application
$n = $o.GetNamespace(“MAPI”)
#you'll get a popup in outlook at this point where you pick the folder you want to scan
$Account = $n.Folders | ? { $_.Name -eq 'name@domain.com' };
$Inbox = $Account.Folders | ? { $_.Name -match 'Inbox' };
$f = $Inbox.Folders | ? { $_.Name -match 'subfolder' };
#string to search for in attachment name
$file = '.xlsx'
#now loop through them and grab the attachments
$f.Items | foreach {
$_.attachments | foreach {
Write-Host $_.filename
$a = $_.filename
$b = 'Rename ' + $a
If ($a.Contains($file)) {
$_.saveasfile((Join-Path $filepath $b))
}
}
}
帖子已更新。
此脚本适用于我自己的邮箱。我虽然有一个公共文件夹 添加到我的 Outlook 中,是否可以访问 通过调整此脚本来创建公共文件夹?
【问题讨论】:
标签: excel email outlook powershell-2.0 extract