Launch Outlook to compose a message with subject and attachment by Outlook's command line switches

眉间皱痕 提交于 2019-11-29 07:09:24
Robb Jones

So far from what I've discovered with Outlook 2007 is that in order to achieve this you have to realize that /a implies /c IPM.note.

So using

outlook.exe /a "FileName" /m "addresses&cc=&subject=&body="

Works just fine (took me forever to figure this out cause everyone on the web appears to insist that you must use /c when doing /m but not taking into account that /a does this for you automatically.

Also, I've noticed that using %20 isn't exactly correct when needing to put spaces, instead %2 (%20 without the 0) is doing the trick there. Otherwise you'll end up with a bunch of 0's after all the spaces, very strange indeed.

I'm going to add this here.

Every time I get a new PC, I have to configure my Task Scheduler to launch my daily email to management. Every time I search, I come across this one, but it isn't quite what I want.

I want a daily email to be sent to a group entitled "DailyLog" with the Subject="Daily Log" (I didn't say I was being original).

I start with this KB from Microsoft:

How to use command line switches to create a pre-addressed e-mail message in Outlook

Here are the screenshots for that, but the only one you really need to pay attention to is the Action tab:

In the image above, the Actions tab is where all of the important information goes.

Depending on your version of Microsoft Outlook, your path could look different.

Notice the Program/script section needs to be in quotes. The Add arguments (optional) is NOT in quotes!

Here is what I use in the arguments text box:

/c ipm.note /m DailyLogGroup;&subject=Daily%20Log

The /c switch creates the message (ipm.note), and the /m switch places the group DailyLogGroup in the TO field with the text Daily Log in the subject (%20 is a blank space).

Outlook > Tools > Forms > DesignForm > Message > Open

    To = "abc@xyz.com"

ViewCode

    Function Item_Open()
    If Item.Size = 0 Then : Item.Send : End If
    End Function

File > Close > Publish > PublishFormAs

    DisplayName = "test_130713_0856"

Publish > [CLOSE] > Yes

send_email.bat
--------------
"C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" ^
    /c "IPM.Note.test_130713_0856" ^
    /m "abc@xyz.com&subject=hello world&body=blah blah blah" ^
    /a h:\test.txt
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!