sp_processmail

Description

Windows NT only Reads, processes, sends, and deletes messages in the Adaptive Server message inbox, using the xp_findnextmsg, xp_readmail, xp_sendmail, and xp_deletemail system extended stored procedures (ESPs).

Syntax

sp_processmail [subject] [, originator [, dbuser
	[, dbname [, filetype [, separator]]]]]

Parameters

subject

is the subject header of the message. If you specify a subject but not an originator, sp_processmail processes all unread messages in the inbox that has the specified subject header. If you specify both subject and originator, sp_processmail processes all unread messages with the specified subject header sent by the specified originator. If you do not specify either subject or originator, sp_processmail processes all the unread messages in the Adaptive Server message inbox.

originator

is the sender of an incoming message. If you specify an originator and do not specify a subject, sp_processmail processes all unread messages in the inbox sent by the specified originator.

dbuser

specifies the Adaptive Server login name to use for the user context for executing the query in the message. The default is “guest.”

dbname

specifies the database name to use for the database context for executing the query in the message. The default is “master.”

filetype

specifies the file extension of the attached file that contains the results of the query. The default is “.txt”.

separator

specifies the character to use as a column separator in the query results. It is the same as the /s option of isql. The default is the tab character.

Examples

Example 1

Processes all unread messages in the Adaptive Server inbox with the subject header “SQL Report” submitted by mail user “janet”, processes the received queries in the salesdb database as user “sa”, and returns the query results to “janet” in a .res file attached to the mail message. The columns in the returned results are separated by semicolons:

sp_processmail @subject="SQL REPORT", @originator="janet", @dbuser="sa", 
	@dbname="salesdb", @filetype="res", @separator=";"

Example 2

Processes all unread messages in the Adaptive Server inbox as user “sa” in the master database and returns the query results in .txt files, which are attached to the mail messages. The columns in the returned results are separated by tab characters:

sp_processmail @dbuser="sa"

Usage

Permissions

Only a System Administrator can execute sp_processmail.

See also

Extended stored procedures xp_deletemail, xp_findnextmsg, xp_readmail, xp_sendmail, xp_startmail

Utility isql