xp_startmail Extended Stored Procedure

Starts a SQL Server mail client session.

Syntax

xp_startmail ['user'] [, 'password']

where

user
Is an optional parameter specifying a mail username.
password
Is the mail password for the named user. NULL is allowed when the mail client is started (on the same computer) before running xp_startmail.

Remarks

If user and password are provided, SQL Server attempts to log on to Windows NT Mail (or other MAPI provider) using that username and password. If user and password are provided but are incorrect, an error message is returned. If no user or password are provided, SQL Server uses the username and password specified in SQL Setup, using the Mail Login dialog box under Server Options.

If there is an existing mail session, xp_startmail will not start a new one. If mail is being used on the same computer on which SQL Server is also running, the mail client must be started before xp_startmail is used or before SQL Server (if using the Set Server Options "Auto Start Mail Client" option found in SQL Setup). For more information, see the Microsoft SQL Server Administrator's Companion.

Examples

A.    No Variables with xp_startmail

This example starts mail using the username and password specified in SQL Setup.

xp_startmail
B.    Variables with xp_startmail

This example starts mail using the username mailuser and the password abc12345.

xp_startmail 'mailuser', 'abc12345'

Permission

Execute permission defaults to the system administrator, who can grant permission to other users.

See Also

sp_processmail xp_readmail
xp_deletemail xp_sendmail
xp_findnextmsg xp_stopmail