Microsoft KB Archive/287573

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

Article ID: 287573

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Office Outlook 2007
 * Microsoft Office Outlook 2003
 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q287573





For a Microsoft Outlook 2000 version of this article, see 197782.



For a Microsoft Outlook 98 version of this article, see 181991.



For a Microsoft Outlook 97 version of this article, see 172958.



SUMMARY
This article describes how to use command line switches to create a new e-mail message that is pre-addressed (with the To field filled in automatically). You can do this in one of the following ways:
 * Using a desktop shortcut.
 * Using the Shell command.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

How to use a desktop shortcut
To create a shortcut on your Windows desktop that automatically creates a new pre-addressed e-mail message, follow these steps:  Right-click a blank area of your Windows desktop, point to New, and then click Shortcut. In the Command Line box, type the following

&quot;C:\Program Files\Microsoft Office\Office10\Outlook.exe&quot; /c ipm.note /m 

In this command,  is the complete e-mail address of the recipient (For example, JohnDoe@msn.com.)

NOTE: You may have to modify the path if you did not install Outlook to the default setup location.

 Type a name for the shortcut, for example, Mail to John Doe. Click Finish.</li></ol>

NOTE: If you want to use a custom form in your desktop shortcut, use its message class rather than IPM.Note. For example, if the custom form you want to use has a display name of &quot;MyForm,&quot; (without quotation marks) then the message class should be IPM.Note.MyForm, and the following is the command used to create a message using the custom form:

&quot;C:\Program Files\Microsoft Office\Office\Outlook.exe&quot; /c ipm.note.myform /m <full e-mail name>

How to use the &quot;Shell&quot; command
To automatically create a new pre-addressed Outlook e-mail message by using the Shell command, follow these steps: <ol> Start Microsoft Word.</li> On the Tools menu, point to Macro, and then click Macros.</li> In the Macro Name box, type SendMail, and then click Create.</li> Type the following sample code in the Visual Basic for Applications editor

Shell &quot;C:\Program Files\Microsoft Office\Office\Outlook.exe /c ipm.note /m <full e-mail name>&quot;

In this command, <full e-mail name> is the complete e-mail address of the recipient (for example, JohnDoe@msn.com.)

</li> On the File menu, click Close and Return to Microsoft Word.</li> On the Tools menu, point to Macro, and then click Macros.</li> In the Macro Name box, click to select SendMail, and then click Run. The SendMail macro creates a new e-mail message addressed to the recipient that you chose in step 4.</li></ol>

If Outlook is running, the e-mail message opens quickly. If Outlook is not running, there is a delay while the Windows Messaging System starts in the background.

NOTE: Using the Shell command is very restrictive. You can better automate the contents of a new e-mail message with Visual Basic for Applications or VBScript.

Single command-line string for a message with subject and body
NOTE: The procedures that are outlined in this section assume that the you are familiar with creating the type of objects listed in the implementation list.

In order to create a preformatted and pre-addressed e-mail message, it is necessary to build a command-line string with the following parameters:

mailto: ?cc= &bcc=<bcc

mail>&subject= &body=

Where the following variable definitions apply: <pre class="fixed_text">  Variable                        Field Entry --  <to e-mail>          e-mail address to appear in the To field e-mail address to appear in the CC field e-mail address to appear in the BCC field text to appear in the Subject field text to appear in the Body of the message

Note the position of the question mark (?) and ampersand (&) characters in the command-line syntax.

In addition to the field designations, you must use ASCII hexadecimal equivalents as variables for punctuation characters. The following variables are used to represent commonly used characters:

Space %20

Comma %2C

Question Mark (?) %3F

Period (.) %2E

Exclamation Point (!) %21

Colon %3A

Semicolon %3B

The following is an example of a command-line that populates the To, the Subject, and the Body fields in a new e-mail message:

mailto:johndoe@domain.com&subject=Hello%20World%21&body=How%20are%20you%2C%20John%3F

This command-line yields the following information:

Recipient: johndoe@domain.com Subject: Hello World! Body: How are you, John?

Uses of the Command line String
This command line string may be used in the following implementations:
 * In the Open box of Run command line.
 * In Properties of your desktop shortcut
 * In the Address Bar of Internet Explorer 4.0.
 * In the Subject line of an Outlook e-mail message.
 * In the body of an Outlook or Outlook Express e-mail message.
 * In the Hypertext Markup Language (HTML) code of a Web page.

Keywords: kbhowto kbinfo KB287573

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.