I’ve created a powershell script along this line.
$ol=new-object -comobject outlook.application
$mail=$ol.createitem(0)
$mail.subject=(get-content $subject)
$mail.attachments.add($attachment)
$inspector=$mail.getinspector
$inspector.display()
But now I’m stuck on the following simple issue:
How do I get focus on the newly created message? Sometimes it does appear in the foreground, but not always. How do I force it to the foreground?
Try using the Inspector.Activate() method instead of MailItem.Display() in order to bring the mail message window to the foreground. Here’s a quote from MSDN:
So your script should be: