how can I run this powershell script as a Windows Service?
$olSaveType = "Microsoft.Office.Interop.Outlook.OlSaveAsType" -as [type]
Add-Type -Assembly "Microsoft.Office.Interop.Outlook" $Outlook =
New-Object -ComObject Outlook.Application $Namespace =
$Outlook.GetNameSpace("MAPI")
$EmailsInFolder= $NameSpace.GetDefaultFolder(6).Folders.Items
$EmailsInFolder | ft SentOn, Subject, Sensitivity -AutoSize -Wrap
foreach ($EmailInFolder in $EmailsInFolder)
{
$EmailInFolder.Subject = "Test"
$EmailInFolder.Save()
}
I like to change the email subject when I move the email in a folder.
Regards Stefan