Using XP_FindNextMSG
FindNextMSG lets you move through the inbox, seeing the messages that are available. It
has an Unread_ONLY flag that you can set, making it easier to process only pending
messages, leaving others in the inbox.
xp_findnextmsg [[@msg_id =] 'message_number' [OUTPUT]]
[,[@type =] type]
[,[@unread_only =] 'unread_value'])
The parameters are outlined below:
| Parameter |
Description |
| @msg_id |
ID of the next message |
| @unread_only |
Restricts the search to only unread messages. |
Using XP_ReadMail
When youve found the message you want to read, you can use the ReadMail stored
procedure to pull in the contents and control how it is processed. There are a number of
parameters to this call, each controlling different aspects of how the message is provided
to the SQL process. The syntax is shown below, the parameters are outlined in the table
following the listing.
xp_readmail [[@msg_id =] 'message_number'] [, [@type =] 'type' [OUTPUT]]
[,[@peek =] 'peek']
[,[@suppress_attach =] 'suppress_attach']
[,[@originator =] 'sender' OUTPUT]
[,[@subject =] 'subject' OUTPUT]
[,[@message =] 'message' OUTPUT]
[,[@recipients =] 'recipients [;
n]' OUTPUT]
[,[@cc_list =] 'copy_recipients [;
n]' OUTPUT]
[,[@bcc_list =] 'blind_copy_recipients [;
n]' OUTPUT]
[,[@date_received =] 'date' OUTPUT]
[,[@unread =] 'unread_value' OUTPUT]
[,[@attachments =] 'attachments [;
n]' OUTPUT])
[,[@skip_bytes =] bytes_to_skip OUTPUT]
[,[@msg_length =] length_in_bytes OUTPUT]
[,[@originator_address =] 'sender_address' OUTPUT]]
| Parameter |
Description |
| @msg_id |
ID of the next message |
| @originator |
The returned email address of the user sending the message.
It can only be 255 characters. |
| @subject |
The subject of the message. Can only be 255 characters. |
| @message |
This is the text of the mail message which is normally a
query to execute. This variable is only capable of handling 8000 characters. |
| @recipients |
This is a semicolon separated list of recipients |
| @skip_bytes |
This is a hold over from version 6.5 which was used to read
large messages in chunks. It specifies the number of bytes to skip when reading the mail
message. |
| @msg_length |
Used in conjunction with @skip_bytes to sequentially process
255 byte chunks of a message. |
Configuring and Managing SQL Mail 1 2 3 4 5 6 7