I'm trying to get Plain Text or HTML Text of email using AE.Net.Mail. I cannot find any documentation.
using (Pop3Client pop3 = new AE.Net.Mail.Pop3Client("pop3Server", "login", "pwd", 995, true))
{
for (var i = pop3.GetMessageCount() - 1; i >= 0; i--)
{
MailMessage Msg = pop3.GetMessage(i);
string HtmlText = Msg.??????
string PlainText = Msg.??????
}
}
Edit : I found this solution
IList<Attachment> iList;
string HtmlText = "", PlainText = "";
for (var i = pop3.GetMessageCount() - 1; i >= 0; i--)
{
MailMessage msg = pop3.GetMessage(i);
TextBody = msg.Body;
iList = msg.AlternateViews as IList<Attachment>;
if (iList.Count == 0) iList = msg.Attachments as IList<Attachment>;
if (iList.Count > 0)
{
TextBody = iList[0].Body;
HtmlBody = iList[1].Body;
}
}
Body = e.Value.AlternateViews.GetHtmlView().Body,
you must set headers only to false
I solved this problem with this method:
Firt create a class:
Than:
And check has "text/html":
And if has "text/html", body's format html else body's format plain
If your
MailMessage
is theSystem.Net.Mail
one, you can get the message body from theBody
property. It may be either HTML or plain-text depending on theIsBodyHtml
property. TheAlternateViews
property may also contain alternate forms of the message body.