User guide
Table Of Contents
- AWS SDK for .NET
- Table of Contents
- AWS SDK for .NET Developer Guide
- Getting Started with the AWS SDK for .NET
- Programming with the AWS SDK for .NET
- AWS SDK for .NET Tutorials and Examples
- Managing ASP.NET Session State with Amazon DynamoDB
- Tutorial: Creating Amazon EC2 Instances with the AWS SDK for .NET
- Tutorial: Grant Access Using an IAM Role and the AWS SDK for .NET
- Tutorial: Amazon EC2 Spot Instances
- Creating and Using an Amazon SQS Queue with the AWS SDK for .NET
- Creating an Amazon Route 53 Hosted Zone and Adding Resource Record Sets
- Additional Resources
- Document History

ReceiveMessageResponse receiveMessageResponse =
amazonSQSClient.ReceiveMessage(receiveMessageRequest);
The method returns a ReceiveMessageResponse instance, containing the list of messages the
queue contains.
3. The response object contains a ReceiveMessageResult member.This member includes a Messages
list. Iterate through this list to find a specific message, and use the Body property to determine if the
list contains a specified message, as follows:
if (result.Message.Count != 0)
{
for (int i = 0; i < result.Message.Count; i++)
{
if (result.Message[i].Body == messageBody)
{
recieptHandle =
result.Message[i].ReceiptHandle;
}
}
}
Once the message is found in the list, use the ReceiptHandle property to obtain a receipt handle for
the message.You can use this receipt handle to change message visibility timeout or to delete the
message from the queue. For more information about how to change the visibility timeout for a
message, go to ChangeMessageVisibility.
For information about sending a message to your queue, see Send an Amazon SQS Message (p. 60).
For more information about deleting a message from the queue, see Delete a Message from an Amazon
SQS Queue (p. 62).
Delete a Message from an Amazon SQS Queue
You can use the Amazon SDK for .NET to receive messages from an Amazon SQS queue.
To delete a message from an Amazon SQS queue
1. Create and initialize a DeleteMessageRequest instance. Specify the Amazon SQS queue to delete
a message from and the receipt handle of the message to delete, as follows:
DeleteMessageRequest deleteMessageRequest =
new DeleteMessageRequest();
deleteMessageRequest.QueueUrl = queueUrl;
deleteMessageRequest.ReceiptHandle = recieptHandle;
2. Pass the request object as a parameter to the DeleteMessage method. The method returns a De-
leteMessageResponse object, as follows:
Version v2.0.0
62
AWS SDK for .NET Developer Guide
Delete a Message from an Amazon SQS Queue