The specified message is out of range error

360 Views Asked by At

I'm getting the following error for a specific email using a POP3 server:

Rebex.Net.Pop3Exception: The specified message is out of range.

When using:

Dim SequenceNumber As Integer = 0
Dim MailMsg As Rebex.Mail.MailMessage = Nothing
Dim UTF8 As New Text.UTF8Encoding
Dim RebexPop3 as new rebex.Net.Pop3
Dim Message As Rebex.Net.Pop3MessageCollection

SequenceNumber = Message.SequenceNumber 
MailMsg = RebexPop3.GetMailMessage(SequenceNumber)
MailMsg.DefaultCharset = UTF8 ' Error generated when filling UTF8
1

There are 1 best solutions below

1
topshot On

You never set Message to anything so SequenceNumber would be nothing or maybe 0. From their example at http://www.rebex.net/secure-mail.net/features/pop3.aspx

' get list of all messages
Dim list As Pop3MessageCollection = pop3.GetMessageList(Pop3ListFields.Fast)

' print some info
Console.WriteLine("Found {0} message(s).", list.Count)
For Each info In list
    Console.WriteLine("{0}: {1} [{2}]", info.SequenceNumber, info.UniqueId, info.Length)
Next

Once you set Message as they did list, you would have access to the SequenceNumber property of each item in the list as they show in the For Each loop.