How can i get the HTML text portion of the email using this code

Mar 16, 2009 at 6:56 PM
How can i get the HTML text portion of the email using this code

Thanks
Rahul
Coordinator
Mar 22, 2009 at 3:11 PM
I'll show you two case example

Case 1---get e-mail from pop3 mail server
The basic code to get BodyText of e-mail is

using
(Pop3Client cl = new Pop3Client())
{
    cl.UserName = "MyUserName";
    cl.Password = "MyPassword";
    cl.ServerName = "MyServer";
    cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
    cl.Authenticate();
    ///Get first mail of my mailbox
    Pop3Message mg = cl.GetMessage(1);
    String MyHtmlText = mg.BodyText;
}

if the mail is multipart, you can get html text by
    Pop3Message mg = cl.GetMessage(1);
    String MyHtmlText = mg.Contents[0].BodyText;


Case 2---get from text data of mail
You can create Pop3Message object by text data of e-mail.
For examle,if you have a text date in the below
---------------------------------------------------------------------------
+OK 3966 octets
Subject: please tell me how to get html text data
Date: Sat, 21 Mar 2009 00:02:56 +0900
Message-ID: <315CDAF4A2224C62B017DE8>
MIME-Version: 1.0
X-Mailer: Microsoft CDO for Windows 2000

Bodydata....

 .
---------------------------------------------------------------------------
 
you can get Pop3Message object like
    String HtmlTextData = "text data of mail";
    Pop3Message mg = new Pop3Message(HtmlTextData);

and to get html text is
    String MyHtmlText = mg.BodyText;
or
    String MyHtmlText = mg.Contents[0].BodyText;


hope your help.