Introduction to the extended stored procedure for sending, receiving, and automatically processing emails using SQL Mail

Source: Internet
Author: User

Introduction to the extended stored procedure for sending, receiving, and automatically processing emails using SQL Mail

SQL SERVER provides an extended storage process for sending and receiving emails through EXCHANGE or OUTLOOK. The following describes these processes.

1. Start SQL Mail

Xp_startmail @ user, @ password

Both @ user and @ password are optional.

You can also open Support Services in Enterprise Manager, right-click SQL Mail, right-click the menu, and then press Start to Start

Ii. Stop SQL Mail

Xp_stopmail

You can also use Stop in the menu in the above method to Stop

3. Send emails

Xp_sendmail {[@ recipients =] 'recipients [;... n] '}
[, [@ Message =] 'message>
[, [@ Query =] 'query>
[, [@ Attachments =] attachments]
[, [@ Copy_recipients =] 'Copy _ recipients [;... n]'
[, [@ Blind_copy_recipients =] 'blind _ copy_recipients [;... n]'
[, [@ Subject =] 'subject>
[, [@ Type =] 'Type>
[, [@ Attach_results =] 'Attach _ value>
[, [@ No_output =] 'output _ value>
[, [@ No_header =] 'header _ value>
[, [@ Width =] width]
[, [@ Separator =] 'separator>
[, [@ Echo_error =] 'echo _ value>
[, [@ Set_user =] 'user>
[, [@ Dbuse =] 'database>

@ Recipients is required.

Parameter description:

Parameter description
@ Recipients separated by commas
@ Message: the message to be sent.
@ Query: determines whether to execute a valid query that is attached to the email. In addition to the Insert table and delete table in the trigger, this query can reference any object.
@ Attachments attachment
@ Copy_recipients CC
@ Blind_copy_recipients BCC
@ Subject title
@ Attach_results: Specify the query result to be sent as an attachment.
@ No_header: name of the column that does not send the query result
@ Set_user: query the connected user name. The default value is Guset.
@ Dbuse: the database used for query. The default value is the default database.

4. read emails in the inbox

Xp_readmail [[@ msg_id =] 'message _ number> [, [@ type =] 'type' [OUTPUT]
[, [@ Peek =] 'peek>
[, [@ Suppress_attach =] 'reress _ attach>
[, [@ Originator =] 'sender' OUTPUT]
[, [@ Subject =] 'subobject' 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:

Parameter description
@ Originator sender
@ Subject topic
@ Message
@ Recipients recipient
@ Skip_tytes: the number of bytes skipped when reading mail information. It is used to obtain Mail Information segments in sequence.
@ Msg_length: determines the length of all information. It is usually processed with @ skip_bytes.

5. process the next email in sequence

Xp_findnextmsg [[@ msg_id =] 'message _ number' [OUTPUT]
[, [@ Type =] type]
[, [@ Unread_only =] 'unread _ value>)

6. delete emails

Xp_deletemail {'message _ number '}

If no email number is specified, all emails in the inbox are deleted.

7. automatically process emails

Sp_processmail [[@ subject =] 'subject>
[, [@ Filetype =] 'filetype>
[, [@ Separator =] 'separator>
[, [@ Set_user =] 'user>
[, [@ Dbuse =] 'dbname>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.