AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Composes an email message and immediately queues it for sending.

This operation is more flexible than the SendEmail operation. When you use the SendRawEmail operation, you can specify the headers of the message as well as its content. This flexibility is useful, for example, when you need to send a multipart MIME email (such a message that contains both a text and an HTML version). You can also use this operation to send messages that include attachments.

The SendRawEmail operation has the following requirements:

Additionally, keep the following considerations in mind when using the SendRawEmail operation:

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to SendRawEmailAsync.

Namespace: Amazon.SimpleEmail
Assembly: AWSSDK.SimpleEmail.dll
Version: 3.x.y.z

Syntax

C#
public abstract SendRawEmailResponse SendRawEmail(
         SendRawEmailRequest request
)

Parameters

request
Type: Amazon.SimpleEmail.Model.SendRawEmailRequest

Container for the necessary parameters to execute the SendRawEmail service method.

Return Value


The response from the SendRawEmail service method, as returned by SimpleEmailService.

Exceptions

ExceptionCondition
AccountSendingPausedException Indicates that email sending is disabled for your entire Amazon SES account. You can enable or disable email sending for your Amazon SES account using UpdateAccountSendingEnabled.
ConfigurationSetDoesNotExistException Indicates that the configuration set does not exist.
ConfigurationSetSendingPausedException Indicates that email sending is disabled for the configuration set. You can enable or disable email sending for a configuration set using UpdateConfigurationSetSendingEnabled.
MailFromDomainNotVerifiedException Indicates that the message could not be sent because Amazon SES could not read the MX record required to use the specified MAIL FROM domain. For information about editing the custom MAIL FROM domain settings for an identity, see the Amazon SES Developer Guide.
MessageRejectedException Indicates that the action failed, and the message could not be sent. Check the error stack for more information about what caused the error.

Examples

The following example sends an email with an attachment:

SendRawEmail


var client = new AmazonSimpleEmailServiceClient();
var response = client.SendRawEmail(new SendRawEmailRequest 
{
    Destinations = new List<string> {
                    
    },
    FromArn = "",
    RawMessage = new RawMessage { Data = new MemoryStream(From: sender@example.com\nTo: recipient@example.com\nSubject: Test email (contains an attachment)\nMIME-Version: 1.0\nContent-type: Multipart/Mixed; boundary="NextPart"\n\n--NextPart\nContent-Type: text/plain\n\nThis is the message body.\n\n--NextPart\nContent-Type: text/plain;\nContent-Disposition: attachment; filename="attachment.txt"\n\nThis is the text in the attachment.\n\n--NextPart--) },
    ReturnPathArn = "",
    Source = "",
    SourceArn = ""
});

string messageId = response.MessageId;

            

Version Information

.NET Framework:
Supported in: 4.5 and newer, 3.5

See Also