Search The ForumSearch   RegisterRegister  LoginLogin

MailBee Objects

 AfterLogic Forum : MailBee Objects
Subject Topic: Read messages Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Guests
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 24 May 2004 at 5:41pm | IP Logged Quote Guests

Hello,

I am using Mailbee's pop3 object, how do i restrict my RetrieveMessages method to pnly new messages.

Thanks
prasad challa
Back to Top View Guests's Profile Search for other posts by Guests
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 25 May 2004 at 5:24am | IP Logged Quote Alex

Basically, the POP3 protocol has no features to determine whether a message is new or not.

However, the POP3 protocol allows you to get list of Unique-ID's of all messages in the mailbox.

The procedure is as follows:

On every connection to POP3 server, get list of Unique-ID's of all messages in the mailbox.

Then, check which of these ID's are already in database. Those ID's which already in database, correspond to old messages. If particular ID is not in database, it is a new message: download it completely!

Once all new messages are retrieved, update database with recent version of Unique-ID's list.

Thus, on very first connection the database is empty (and all messages are new). Next times the procedure will retrieve only new messages.

To get list of Unique-ID's, use Search method of POP3 object.

Sample code below shows MailBee part of the procedure discussed above. IsNewMessage function is empty, in your code it should actually lookup passed Unique-ID value in the database.

' This is main function. It retrieves new messages from
' the POP3 server and shows "Subject:" field of each
' retrieved message.
Sub RetrieveNewMessages()
Dim objPOP3, objMsg, I

' Array of Unique-IDs (taken from the POP3 server)
Dim arrIDs

' Create POP3 object
Set objPOP3 = CreateObject("MailBee.POP3")

' Unlock POP3 object
objPOP3.LicenseKey = "put your license key here"

' Set POP3 server name
objPOP3.ServerName = "mail.server.com"

' Set user credentials
objPOP3.UserName = "username"
objPOP3.Password = "password"

' Connect to the server and log in the mailbox
If objPOP3.Connect Then

    ' Get Unique-IDs for all messages in the mailbox
    arrIDs = objPOP3.Search

    ' Iterate through all messages in the mailbox
    For I = 1 To objPOP3.MessageCount

      ' Search Unique-ID of the message in the database
      If IsNewMessage(arrIDs(I)) Then
      
        ' Download new message entirely
        Set objMsg = objPOP3.RetrieveSingleMessage(I)
       
        ' Display the message's Subject
        MsgBox objMsg.Subject
      End If
    Next

    ' Close the connection
    objPOP3.Disconnect
Else
    ' Display error information
    MsgBox "Error #" & objPOP3.ErrCode
    MsgBox "Server response: " & objPOP3.ServerResponse
End If
End Sub

' This helper function should lookup the ID in the
' database, and then return True if the ID does not
' exist in the list of already downloaded messages.
Function IsNewMessage(ID)
' For demo purposes, the function always returns True.
IsNewMessage = True
End Function
Back to Top View Alex's Profile Search for other posts by Alex
 
Guests
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 14 September 2004 at 8:55pm | IP Logged Quote Guests

Back to Top View Guests's Profile Search for other posts by Guests
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 15 September 2004 at 6:01am | IP Logged Quote Alex

Could you describe in more detail what did you mean?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

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