Deleted Lauren's post and reposting the contents after removing
password.

--
Cerebrus.
Group Moderator.

On Oct 23, 12:37 pm, Lauren <[email protected]> wrote:

Hi,

I already have most of the code to do this, however, I need to check
whether certain text appears in the email subject, and then add the
body of the email to a comment table. Also, the current code displays
all the header info from the mail which I don't want.


I got this code from a site:


protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            TcpClient tcpclient = new TcpClient();
            tcpclient.Connect("pop.gmail.com", 995);


            System.Net.Security.SslStream sslstream = new SslStream
(tcpclient.GetStream());
            sslstream.AuthenticateAsClient("pop.gmail.com");


            System.IO.StreamWriter sw = new StreamWriter(sslstream);
            System.IO.StreamReader reader = new StreamReader
(sslstream);


            sw.WriteLine("USER [email protected]"); //Send
email
address
            sw.Flush();


            sw.WriteLine("PASS somepassword"); //Send password
            sw.Flush();


            sw.WriteLine("RETR 1"); //Retrieve first email
            sw.Flush();


            sw.WriteLine("Quit"); //Close the connection
            sw.Flush();


            string str = string.Empty;
            string strTemp = string.Empty;


            while ((strTemp = reader.ReadLine()) != null)
            {
                if (strTemp == ".")
                {
                    break;
                }


                if (strTemp.IndexOf("-ERR") != -1)
                {
                    break;
                }


                str += strTemp;
             }


            Response.Write(str); //Display the message
            //Response.Write("<br/>" + "WHOO HOO - it works!");
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }


    }


Any help would be appreciated, I basically just want to check the
email subject for certain text, and extract the body of the email.


Thanks,
Lauren

Reply via email to