我在哪里将我的行放在此代码中以输出到文件?我希望它能够在处理电子邮件的过程中构建它,但我无法辨别它在哪里发生。
老实说,我无法弄清楚输出行语法应该是什么。像这样的东西(IDK):
$Email | select SentOn, SenderName, Subject, bodysubstring | Format-Table -Auto | out-file c:\results.txt
以下是完整的代码。我正在尝试将我的电子邮件基本信息写入文本文件,我可以在旅行时检查。非常感谢您的帮助。
#connect to outlook
$GetOutlook = New-Object -com "Outlook.Application";
$olName = $GetOutlook.GetNamespace("MAPI")
$olxEmailFolder = $olName.GetDefaultFolder(‘playdude@playboy.com’)
$olxEmailFolder.Name
$olxEmailItem = $olxemailFolder.items
#show unread emails in inbox
$olxEmailItem | select SentOn, SenderName, Subject, @{n='bodysubstring';e={$_.body.substring(0,100)}} | Format-Table -auto
#go through each subfolder and get name
$SubFolders = $olxEmailFolder.Folders
ForEach($Folder in $SubFolders)
{
$Folder.Name
$SubfolderItem = $Folder.Items
$EmailCount = 1
#create status bar for each subfolder
ForEach($Email in $SubfolderItem)
{
Do
{
Write-Progress -Activity "Checking folder" -status $Folder.Name -PercentComplete ($EmailCount/$Folder.Items.Count*100)
$EmailCount++
}
#show unread emails from subfolders
While($EmailCount -le $Folders.Item.Count)
}
}