SendMailMessage
Sends the message specified to the specified recipient.
Stored Procedure Specific Information
Send an email by using this procedure
Example to attach only one file:
EXECUTE SendMailMessage @Subject='subject', @To='email', @CC='email', @Content='content', @AttachmentPath='C:\\MyDirectory\\MyFile.extension'
Example to attach all files of the first level on a directory:
EXECUTE SendMailMessage @Subject='subject', @To='email', @CC='email', @Content='content', @AttachmentPath='C:\\MyDirectory'
Example to attach a combination of multiple files and folders:
Insert into attach#temp (AttachmentPath) VALUES ('C:\\MyDirectory\\MyFile.extension') Insert into attach#temp (AttachmentPath) VALUES ('C:\\MyDirectory') EXECUTE SendMailMessage @Subject='subject', @To='email', @CC='email', @Content='content', @AttachmentPath='attach#temp'
Note: This procedure makes use of indexed parameters. These input parameters are denoted with a '#' character at the end of their names.
Indexed parameters facilitate providing multiple instances a single parameter as inputs for the procedure.
Suppose there is an input parameter named Param#. Input multiple instances of an indexed parameter like this:
EXEC ProcedureName Param#1 = "value1", Param#2 = "value2", Param#3 = "value3"
Input
Name | Type | Required | Description |
To | String | True | The email address of the recipient. |
From | String | False | The email addresses of the sender. |
Subject | String | True | The subject of the mail message. |
Content | String | True | The message body. |
CC | String | False | CCed recipient. |
BCC | String | False | BCCed recipient. |
AttachmentPath | String | False | A semicolon-separated list of the attachment file names (with the path if reading from a file) included in the message. |
Result Set Columns
Name | Type | Description |
Id | String | The Id for the message as returned by the server. |