0
我想從Outlook中的電子郵件中提取.xls文件,將其重命名並將其保存到文件夾中。我找到了一些腳本,但是其中沒有一個腳本完全按照我的需要實現。從Outlook中提取並重命名.xls的Powershell腳本
已更新。
我發現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 '[email protected]' };
$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中,是否可以通過調整此腳本來訪問 公用文件夾內的文件夾?