Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET POP3

 AfterLogic Forum : MailBee.NET POP3
Subject Topic: This should be simple??? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
zcast
Newbie
Newbie
Avatar

Joined: 10 July 2011
Location: United States
Online Status: Offline
Posts: 15
Posted: 10 July 2011 at 4:58pm | IP Logged Quote zcast

Hello All,

This is my first post :)! Can someone please tell me why this code does NOT work?

Imports MailBee.Mime
Imports MailBee.Pop3Mail

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
      Try
        Pop3.LicenseKey = "TRIAL"

        Dim pop As New Pop3
        pop.Connect("pop.myserver.com")
        pop.Login("MyUsername", "MyPassword")

      Dim msgs As MailMessageCollection = pop.DownloadMessageHeaders()
        Dim uids() As String = pop.GetMessageUids()
        Dim msg As MailMessage
        For Each msg In msgs
            Dim item As ListViewItem = New ListViewItem

            item.SubItems.Add(msg.From.AsString)
            item.SubItems.Add(msg.To.AsString)
            item.SubItems.Add(msg.Subject)
            item.SubItems.Add(msg.Date.ToString())
            item.SubItems.Add(msg.SizeOnServer.ToString())
            item.SubItems.Add(msg.UidOnServer.ToString())
            ' Add new item to list view.
            listViewMsgs.Items.Add(item)
            Application.DoEvents()
        Next
       Catch ex As Exception
        msgbox(ex.message)
    End Sub

I have a form with a listview to download message headers into and parse them into their perspective columns, but the UIDOnServer.ToString keeps throwing a " Object Reference not set to an instance of an object". I am VERY new to VB and Mailbee component, so any help would be appreciated. Thank you.

Zcast
Back to Top View zcast's Profile Search for other posts by zcast
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 10 July 2011 at 10:25pm | IP Logged Quote Igor

Documentation on UidOnServer property suggests the following type conversion:

Code:
Dim pop3UID As String = CType(msgPop3.UidOnServer, String)

Does it work for you?

It could be that your particular mail server doesn't support UIDs, in which case UidOnServer would return null reference.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
zcast
Newbie
Newbie
Avatar

Joined: 10 July 2011
Location: United States
Online Status: Offline
Posts: 15
Posted: 11 July 2011 at 8:23am | IP Logged Quote zcast

Thanks Igor for your quick reply. This is the code that finally worked for me, kust add the preload options, and everything works great now. Thanks for your help.

Try
            Dim pop As New Pop3
            pop.InboxPreloadOptions = Pop3InboxPreloadOptions.Uidl
            pop.Connect("pop.myserver.com")
            pop.Login("MyUsername", "MyPassword")

            Dim msgs As MailMessageCollection = pop.DownloadMessageHeaders()

            Dim msg As MailMessage

            For Each msg In msgs
               Dim item As ListViewItem = New ListViewItem
              
               item.SubItems.Add(msg.UidOnServer)
               item.SubItems.Add(msg.From.AsString)
               item.SubItems.Add(msg.To.AsString)
               item.SubItems.Add(msg.Subject)
               item.SubItems.Add(msg.Date.ToString())
               item.SubItems.Add(msg.SizeOnServer.ToString())

               ' Add new item to list view.
               listViewMsgs.Items.Add(item)
               Application.DoEvents()
              Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
      
    End Sub
Back to Top View zcast's Profile Search for other posts by zcast
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide