3

I'm trying to write a powershell script (which will run periodicaly) for opening the new email windows of outlook with "to", "subject" and "body" filled with some data.

I found a way to send mails from powershell but you have to send it from powershell. this doesn't fit the need because I have to edit the body of the mail.

$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "random.dude@email.com"
$Mail.Subject = "data for Subject"
$Mail.Body ="Example of body..."
$Mail.Send()

Basicaly what i need is a $Mail.Show() wich will open a new e-mail popup with the data pre-filled

powershell is not a requirement, it just seams able to manipulate outlook so I tried with it.

XioRcaL
  • 653
  • 2
  • 11
  • 23

2 Answers2

5

thanks to this thread, the $Mail.Show() is actually $Mail.Display()

Community
  • 1
  • 1
XioRcaL
  • 653
  • 2
  • 11
  • 23
  • 3
    There's always the Mailto URI scheme `mailto:the@dude.org?subject=OhHai&Body=WhatsUp`. From cmd.exe `start "mailto:the@dude.org?subject=OhHai&Body=WhatsUp"` – evilSnobu Oct 29 '14 at 10:52
  • Or Send-MailMessage from PowerShell with -Body that you get from a Read-Host variable (or text file?) <- The best part here is that you don't need Outlook at all. – evilSnobu Oct 29 '14 at 10:58
  • My preference goes to powershell, but yeah the cmd mailto: could do the trick, thanks for pointing it out! the point of all that is to have a template of mail showing up at different times; the user should then complete the template. that's why I need the outlook windows to shows up :) – XioRcaL Oct 29 '14 at 14:36
2

I know this is a little late however if you add the following to your script removing your $Mail.Send() line it should open the email ready for editing:

$mail.save()
$inspector = $mail.GetInspector
$inspector.Display()
Harry
  • 175
  • 1
  • 2
  • 6