User guide

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. 62).
For more information about deleting a message from the queue, see Delete a Message from an Amazon
SQS Queue (p. 64).
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
DeleteMessageResponse object, as follows:
Version v2.0.0
64
AWS SDK for .NET Developer Guide
Delete a Message from an Amazon SQS Queue