25

Is this possible? I want to have the To:, Body, and an Attachment all pre-populated so all the user has to do is click send. Thanks!

skb
  • 30,624
  • 33
  • 94
  • 146

3 Answers3

47

Open a new mail message (ipm.note is the message class for emails)

outlook.exe /c ipm.note

Open a new mail message and populate sender:

outlook.exe /c ipm.note /m someone@microsoft.com

Open a new mail message with attachment:

 outlook.exe /c ipm.note /a filename

Combination: (First one below didn't work in Office 2016, second did)

 outlook.exe /c ipm.note /m someone@microsoft.com&subject=test%20subject&body=test%20body
 outlook.exe /c ipm.note /m "someone@microsoft.com&subject=test%20subject&body=test%20body"

The %20 has to be used to produce a blank space.

This works for instance with a classic Outlook 2016 (build 16.0.4849.1000).

But, as Snozzlebert notes in the comments, for a Outlook 365 Version 2001 (Build 12430.20184) the syntax would be:

outlook.exe /c ipm.note /m "someone@microsoft.com?subject=test"

the culprit was the & after the email-address - replacing it with ? solved the problem.
It seems that Microsoft changed the syntax to the HTML mailto syntax.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Neat. The command-line is having a renaissance at Microsoft, it seems. – JesperE Oct 29 '08 at 22:05
  • Cool, I didn't know that - and I probably never would have tried. – Tomalak Oct 29 '08 at 22:13
  • 1
    Awesome! But it doesn't allow you to attach a file AND fill in the To/Body of the email. Try it out. It doesn't work. Also, the value of the /m parameter should be surrounded with quotes. I had to do that to get it to work because apparently the & means something to the shell interpreter. TY! – skb Oct 30 '08 at 16:51
  • You are correct. It seem command-line can only get you so far... – VonC Oct 30 '08 at 18:01
  • @VonC What if we want it to send right out without having to click send. – Mowgli Mar 14 '13 at 19:57
  • @Mowgli not sure, actually. It could be the base for a new question. – VonC Mar 15 '13 at 06:12
  • @VonC sorry to ask question in existing topic, but I tried searching for this whole day yesterday and couldn't find solution only this post closely related and you look like most experienced with 285k so I asked. I'll still start another new question in outlook and cmd section Thanks. – Mowgli Mar 15 '13 at 12:20
  • @Mowgli I understand, and you did well asking it here first, but (since I don't have an immediate answer) a separate question (with a link back to this one) will be more effective. – VonC Mar 15 '13 at 12:33
  • Can anybody confirm if this still works with Outlook Version 2001 (Build 12430.20184)? The subject line is empty if I use the following command: `outlook.exe /c ipm.note /m "someone@microsoft.com&subject=test"` – domids Feb 07 '20 at 09:45
  • 1
    @Snozzlebert 11+ years later (after writing this answer), I just tested it, with an Outlook 2016 at work (build 16.0.4849.1000). It does work (still). I don't know for version 2001. – VonC Feb 07 '20 at 09:54
  • @VonC Thank you for testing. I seem to have Outlook 365 Version 2001 (In Outlook under `File > Office Account > About Outlook` it just states Version 2001). The reason I'm asking is because a user has reported a problem and now I have the same problem (it worked a few days ago). Anyway the problem is fixed now - **the culprit was the `&` after the email-address - replacing it with `?` solved the problem** - e.g. `outlook.exe /c ipm.note /m "someone@microsoft.com?subject=test"`. It seems that Microsoft changed the syntax to the HTML mailto syntax. – domids Feb 07 '20 at 10:03
  • @Snozzlebert Thank you. I have edited the answer to include your comment for more visibility. – VonC Feb 07 '20 at 11:54
9

You can attach files AND pre-fill in the To/Body if you simply place " " quotes around the command after the /m

Example:

outlook.exe /c ipm.note /m "someone@microsoft.com&subject=test%20subject&body=test%20body" /a test.txt
oers
  • 18,436
  • 13
  • 66
  • 75
Dial-IN
  • 91
  • 1
  • 1
3

VonC's solution works, but as stated in the comments by skbergam it doesn't allow for attachments.

If, like me, that's a biggie then the following WSH code does it.

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)

With olMsg
  .To = "test@testing.com"
  '.CC = "cc@testing.com"
  '.BCC = "bcc@testing.com"
  .Subject = "Subject"
  .Body = "Body"
  .Attachments.Add "C:\path\to\attachment\test.txt" 

  .Display
End With

I've tried it with Outlook2003

Allain Lalonde
  • 91,574
  • 70
  • 187
  • 238