We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Clarify below question

Here’s the code:


poEmail is MailMessage

foreach (Attachment poAttachment in poEmail.Attachments)
{
try
{
string psContent = poAttachment.???
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}

}

How to get the text contents of the attachment?

Hi Jole,


Thank you for writing to Aspose support team.

Following sample code can be used to retrieve the attachment text.

MailMessage msg = MailMessage.Load(“Sample.msg”);<o:p></o:p>

Attachment att = msg.Attachments[0];

using (var reader = new StreamReader(att.ContentStream, Encoding.UTF8))

{

var content = reader.ReadToEnd();

File.WriteAllText("AttachmentText.txt", content);

}