xp_startmail (T-SQL)

Starts a SQL Mail client session.

Syntax

xp_startmail [[@user =] 'user'] [,[@password =] 'password']

Arguments
[@user =] 'user'
Is an optional parameter specifying a mail username. user is sysname, with no default.
[@password =] 'password'
Is the mail password for the named user. password is sysname, with no default. A value of NULL is allowed when the mail client is started (on the same computer) before running xp_startmail.
Return Code Values

0 (success) or 1 (failure)

Result Sets

xp_startmail returns this message:

SQL mail session started.

  

Remarks

If user and password are provided, Microsoft® 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 user and password are not provided, SQL Server uses the username and password specified in the SQL Server Properties dialog box.


Note If you use xp_startmail to start your mail sessions, you can optionally supply your login name and password so that you do not have to type it at the command prompt. SQL Mail will “piggyback” an existing client session of Windows NT Mail if one is running.


If there is an existing mail session, xp_startmail does 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 either before xp_startmail is executed, or before SQL Server is started if SQL Mail is configured to automatically start when SQL Server starts.

Permissions

Execute permissions for xp_startmail default to the members of the sysadmin fixed server role but can be granted to other users.

Examples
A. Use no variables with xp_startmail

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

USE master

EXEC xp_startmail

  

B. Use variables with xp_startmail

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

USE master

EXEC xp_startmail 'janetl', 'abc12345'

  

See Also
sp_processmail xp_sendmail
xp_deletemail xp_stopmail
xp_findnextmsg Setting Up SQLAgentMail
xp_readmail System Stored Procedures (SQL Mail Extended Procedures)

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.