'Read Email contents from s3 bucket using C#

we have service which could send emails on s3 bucket whatever emails send on domain "@rmlc.net" now I've to retrieve email from s3 bucket and need to store data in DB using C#

email on s3 buckets are stores in a file format like below screenshot:

s3Bucket.png

here is the code what I've tried using C#

using (var s3Client = new AmazonS3Client("awsAccessKey", "awsSecretKey", Amazon.RegionEndpoint.USEast1))
                {
                    string fileBucket = "lsemails";

                    ListObjectsRequest request = new ListObjectsRequest();

                    ListObjectsResponse response = s3Client.ListObjects(request.BucketName = fileBucket);
                    foreach (S3Object obj in response.S3Objects)
                    {
                        //var data = s3Client.GetObject(obj.BucketName,obj.Key);
                        GetObjectResponse objectResponse = s3Client.GetObject(obj.BucketName, obj.Key);

                        StreamReader reader = new StreamReader(objectResponse.ResponseStream);
                        String content = reader.ReadToEnd();
                        Console.WriteLine(content);

                    }
                }

Output:

output.png

but I'm expecting something similar to this: Amazon SES reading emails stored in an s3 bucket using java from S3ObjectInputStream object

I want to get data in below format:

                        MimeParser parser = new MimeParser(memoryStream);

                        var sub = parser.FirstOrDefault().Subject;
                        var from = parser.FirstOrDefault().From;
                        var recipients = parser.FirstOrDefault().GetRecipients();
                        var htmlContent = parser.FirstOrDefault().GetTextBody(MimeKit.Text.TextFormat.Html);

Any type of help would be appreciated, thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source