OL2000: Command Line for Creating a Pre-addressed E-mail Message

ID: Q197782


The information in this article applies to:
  • Microsoft Outlook 2000


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 the following ways:

  • Using a desktop shortcut.


  • Using the Microsoft Office Shortcut Bar.


  • Using the Shell command.



MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/refguide/

Using a Desktop Shortcut

To create a shortcut on the Windows desktop that automatically creates a new pre-addressed e-mail message, follow these steps:

  1. Using the right mouse button, (right-click) a blank area of the Windows desktop and on the shortcut menu, point to New and click Shortcut.


  2. In the Command Line box, type the following:
    "C:\Program Files\Microsoft Office\Office\Outlook.exe" /c ipm.note /m <full e-mail name>

    where <full e-mail name> is the complete e-mail address of the recipient such as, JohnDoe@msn.com.
    NOTE: You may have to modify the path if you did not install Outlook to the default setup location.


  3. Type a name for the shortcut, for example, Mail to John Doe.


  4. Click Finish.


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 "MyForm," then the message class should be IPM.Note.MyForm, and the command used to create a message using the custom form would be as follows:
"C:\Program Files\Microsoft Office\Office\Outlook.exe" /c ipm.note.myform /m <full e-mail name>

Using the Microsoft Office Shortcut Bar

To add a button to the Office Shortcut Bar to automatically create a new pre-addressed e-mail message, follow these steps:

  1. Right-click the Office Shortcut Bar and on the shortcut menu, click Customize.


  2. On the Buttons tab, click to select the Microsoft Outlook button, and then click OK. The Office Shortcut Bar should now contain an Outlook button.


  3. To add the command line switch to the Outlook button, follow these steps:

    1. Right-click the Microsoft Outlook button on the Office Shortcut Bar, and then click Properties on the shortcut menu.


    2. Click the Shortcut tab.


    3. Click to position the insertion point at the end of the text in the Target box, type a space, and then type the following
      / c ipm.note /m <full e-mail name>
      where <full e-mail name> is the complete e-mail address of the recipient such as JohnDoe@msn.com.




  4. Click OK.


The Outlook button on the Office Shortcut Bar will start Outlook if it is not already running, and create a new e-mail message to JohnDoe@msn.com.

Using the Shell Command

To automatically create a new pre-addressed Outlook e-mail message using the Shell command, follow these steps:

  1. Start Microsoft Word.


  2. On the Tools menu, point to Macro and then click Macros.


  3. In the Macro Name box type SendMail, and then click Create.


  4. Type the following sample code in the Visual Basic for Applications editor
    Shell "C:\Program Files\Microsoft Office\Office\Outlook.exe /c ipm.note /m <full e-mail name>"
    where <full e-mail name> is the complete e-mail address of the recipient such as JohnDoe@msn.com.


  5. On the File menu, click "Close and Return to Microsoft Word."


  6. On the Tools menu, point to Macro, and then click Macros.


  7. In the Macro Name list, click to select SendMail, and then click Run. The SendMail macro should create a new e-mail message addressed to the recipient you chose in step 4.


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 outlined in this section assume that the user is familiar with creating the type of objects listed in the implementation list.

In order to create a preformatted and preaddressed email message it is necessary to build a command line string with the following parameters:

mailto:<to email>?cc=<cc email>&bcc=<bcc mail>&subject=<subject text>&body=<body text>

Where the following variable definitions apply:


   Variable                        Field Entry
   --------------------------------------------------------------
   <to e-mail>          e-mail address to appear in the To field
   <cc mail>            e-mail address to appear in the CC field
   <bcc mail>           e-mail address to appear in the BCC field
   <subject>            text to appear in the Subject field
   <body text>          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 


An example of a command line for the Subject and Body text using these variables would be:


   &subject=Hello%20World%21&body=How%20are%20you%2C%20John%3F 


This command line would yield:


   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 the Start, Run command line.


  • In Properties of a Desktop shortcut


  • In the Address Bar of Internet Explorer 4.0.


  • In the body of an Outlook Express e-mail message.


  • In the HTML code of a Web page.



REFERENCES

For more information about automating Outlook, please see the following articles in the Microsoft Knowledge Base:

Q201096 : OL2000: How to Automate Outlook from Another Program

Q232309 : OL2000: How to Set a Form's From Field Using VBScript

Q146636 : OL2000: Questions About Custom Forms and Outlook Solutions
For more information about Outlook command-line switches, please see the following article in the Microsoft Knowledge Base:
Q197180 : OL2000: Additional Command-Line Switches
For more information about controlling the starting of Outlook, click Microsoft Outlook Help on the Help menu, type "Control what happens when you start Outlook " in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: parameter parameters argument arguments

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 25, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.