Author |
|
zcast Newbie
Joined: 10 July 2011 Location: United States
Online Status: Offline Posts: 15
|
Posted: 10 July 2011 at 4:58pm | IP Logged
|
|
|
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 |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 10 July 2011 at 10:25pm | IP Logged
|
|
|
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 |
|
|
zcast Newbie
Joined: 10 July 2011 Location: United States
Online Status: Offline Posts: 15
|
Posted: 11 July 2011 at 8:23am | IP Logged
|
|
|
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 |
|
|