AWS SDK Version 2 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.

.NET Framework 4.5
 
Container for the parameters to the SendMessage operation. Delivers a message to the specified queue. With Amazon SQS, you now have the ability to send large payload messages that are up to 256KB (262,144 bytes) in size. To send large payloads, you must use an AWS SDK that supports SigV4 signing. To verify whether SigV4 is supported for an AWS SDK, check the SDK release notes.

The following list shows the characters (in Unicode) allowed in your message, according to the W3C XML specification. For more information, go to http://www.w3.org/TR/REC-xml/#charsets If you send any characters not included in the list, your request will be rejected.

#x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.SQS.AmazonSQSRequest
      Amazon.SQS.Model.SendMessageRequest

Namespace: Amazon.SQS.Model
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public class SendMessageRequest : AmazonSQSRequest
         IRequestEvents

The SendMessageRequest type exposes the following members

Constructors

NameDescription
Public Method SendMessageRequest() Empty constructor used to set properties independently even when a simple constructor is available
Public Method SendMessageRequest(string, string) Instantiates SendMessageRequest with the parameterized properties

Properties

NameTypeDescription
Public Property DelaySeconds System.Int32 Gets and sets the property DelaySeconds.

The number of seconds (0 to 900 - 15 minutes) to delay a specific message. Messages with a positive DelaySeconds value become available for processing after the delay time is finished. If you don't specify a value, the default value for the queue applies.

Public Property MessageAttributes System.Collections.Generic.Dictionary<System.String, Amazon.SQS.Model.MessageAttributeValue> Gets and sets the property MessageAttributes.

Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items.

Public Property MessageBody System.String Gets and sets the property MessageBody.

The message to send. String maximum 256 KB in size. For a list of allowed characters, see the preceding important note.

Public Property QueueUrl System.String Gets and sets the property QueueUrl.

The URL of the Amazon SQS queue to take action on.

Examples

This example shows how to send a message.

Send message example

var client = new AmazonSQSClient();

var request = new SendMessageRequest
{
  DelaySeconds = (int)TimeSpan.FromSeconds(5).TotalSeconds,
  MessageAttributes = new Dictionary<string, MessageAttributeValue>
  {
    {
      "MyNameAttribute", new MessageAttributeValue 
        { DataType = "String", StringValue = "John Doe" }
    },
    {
      "MyAddressAttribute", new MessageAttributeValue 
        { DataType = "String", StringValue = "123 Main St." }
    },
    {
      "MyRegionAttribute", new MessageAttributeValue 
        { DataType = "String", StringValue = "Any Town, United States" }
    }
  },
  MessageBody = "John Doe customer information.",
  QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue"
};

var response = client.SendMessage(request);

Console.WriteLine("For message ID '" + response.MessageId + "':");
Console.WriteLine("  MD5 of message attributes: " +
  response.MD5OfMessageAttributes);
Console.WriteLine("  MD5 of message body: " + response.MD5OfMessageBody);
      

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8

.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8