public AlertMessage GetNextMessage()
        {
            //Receiving a message
            ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
            receiveMessageRequest.QueueUrl = queueUrl;
            ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);
            if (receiveMessageResponse.IsSetReceiveMessageResult())
            {
                Console.WriteLine("Printing received message.\n");
                ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                foreach (Message message in receiveMessageResult.Message)
                {
                    AlertMessage m = new AlertMessage();
                    Console.WriteLine("  Message");
                    if (message.IsSetMessageId())
                    {
                        Console.WriteLine("    MessageId: {0}", message.MessageId);
                    }
                    if (message.IsSetReceiptHandle())
                    {
                        Console.WriteLine("    ReceiptHandle: {0}", message.ReceiptHandle);
                    }
                    if (message.IsSetMD5OfBody())
                    {
                        Console.WriteLine("    MD5OfBody: {0}", message.MD5OfBody);
                    }
                    if (message.IsSetBody())
                    {
                        m.Body = message.Body;
                        Console.WriteLine("    Body: {0}", message.Body);
                    }
                    foreach (Amazon.SQS.Model.Attribute attribute in message.Attribute)
                    {
                        Console.WriteLine("  Attribute");
                        if (attribute.IsSetName() && attribute.Name == "Subject")
                        {
                            if (attribute.IsSetValue())
                            {
                                m.Subject = attribute.Value;
                            }
                        }
                        if (attribute.IsSetValue())
                        {
                            Console.WriteLine("    Value: {0}", attribute.Value);
                        }
                    }

                    // Deleting a message
                    Console.WriteLine("Deleting the message.\n");
                    DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
                    deleteRequest.QueueUrl = queueUrl;
                    deleteRequest.ReceiptHandle = message.ReceiptHandle;
                    sqs.DeleteMessage(deleteRequest);

                    return m;
                }
            }
            return null;
        }
        public AlertMessage GetNextMessage()
        {
            FileInfo[] files;
            if ((files = newDir.GetFiles()).Length > 0)
            {
                files[0].MoveTo(Path.Combine(curDir.FullName, files[0].Name + ":2,"));
                SharpMessage message;
                using (FileStream stream = new FileStream(files[0].FullName, FileMode.Open))
                {
                    message = new SharpMessage(stream);
                }

                AlertMessage m = new AlertMessage();
                m.Date = message.Date;
                m.Subject = message.Subject;
                m.Body = message.Body;

                return m;
            }
            else
            {
                return null;
            }
        }
        public AlertMessage GetNextMessage()
        {
            //Receiving a message
            ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();

            receiveMessageRequest.QueueUrl = queueUrl;
            ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);

            if (receiveMessageResponse.IsSetReceiveMessageResult())
            {
                Console.WriteLine("Printing received message.\n");
                ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                foreach (Message message in receiveMessageResult.Message)
                {
                    AlertMessage m = new AlertMessage();
                    Console.WriteLine("  Message");
                    if (message.IsSetMessageId())
                    {
                        Console.WriteLine("    MessageId: {0}", message.MessageId);
                    }
                    if (message.IsSetReceiptHandle())
                    {
                        Console.WriteLine("    ReceiptHandle: {0}", message.ReceiptHandle);
                    }
                    if (message.IsSetMD5OfBody())
                    {
                        Console.WriteLine("    MD5OfBody: {0}", message.MD5OfBody);
                    }
                    if (message.IsSetBody())
                    {
                        m.Body = message.Body;
                        Console.WriteLine("    Body: {0}", message.Body);
                    }
                    foreach (Amazon.SQS.Model.Attribute attribute in message.Attribute)
                    {
                        Console.WriteLine("  Attribute");
                        if (attribute.IsSetName() && attribute.Name == "Subject")
                        {
                            if (attribute.IsSetValue())
                            {
                                m.Subject = attribute.Value;
                            }
                        }
                        if (attribute.IsSetValue())
                        {
                            Console.WriteLine("    Value: {0}", attribute.Value);
                        }
                    }

                    // Deleting a message
                    Console.WriteLine("Deleting the message.\n");
                    DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
                    deleteRequest.QueueUrl      = queueUrl;
                    deleteRequest.ReceiptHandle = message.ReceiptHandle;
                    sqs.DeleteMessage(deleteRequest);

                    return(m);
                }
            }
            return(null);
        }