Need help with OpenPop
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help with OpenPop

  1. #1
    Join Date
    Sep 2011
    Posts
    69

    Question Need help with OpenPop

    Hey,

    I am using OpenPop to read through the emails on my Hotmail account. What I want my code to do is display the HTML link in my email and display it in a listBox but its not working. Can you help?:

    Code:
    
    ///Start POP3 connection
     Pop3Client client = new Pop3Client();
    
    //Login to email
                client.Connect("pop3.live.com", 995, true);
                client.Authenticate("USER", "PASS");
                label18.Text = client.GetMessageCount().ToString();
                int messageCount = client.GetMessageCount();
    
    
                for (int i = 1; i <= messageCount; i++)
                {
                    // Download the header and check if the message is interesting
                    // enough to download if with body
                    MessageHeader header = client.GetMessageHeaders(i);
                    if ("Wordpress".Contains(header.Subject))
                    {
                        // The message is interesting - download it
                        OpenPop.Mime.Message message = client.GetMessage(i);
    
                        // Find the first part containing HTML
                        // null is returned if such part is not found
                        MessagePart html = message.FindFirstHtmlVersion();
                        if (html != null)
                        {
                            String htmlContained = html.GetBodyAsText();
                            // Do something with the html
                            // here showing it in a listbox
                           listBox2.Items.Add(htmlContained);
                        }
                    }
                }
                client.Disconnect();

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,220

    Re: Need help with OpenPop

    Have you tried stepping through the code in a debugger to see what's failing?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center