Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Downloading only mails with Attachment Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Guest
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 02 January 2006 at 8:32am | IP Logged Quote Guest

Hi,
I have a case where i need to download only mails that have attachments.
There will be a large number of messages and only about 40% of them will have attachments.

Whats is the best (speed and memory usage) way to do so?
If you have done anything similar then please do share your experience with me.
Back to Top View Guest's Profile Search for other posts by Guest
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 02 January 2006 at 9:15am | IP Logged Quote Alex

The POP3 protocol (unlike IMAP) does not have any features to detect whether the particular mail has attachments or not without downloading it.

However, MailBee can "guess" whether the message contains attachments or not by analysing message headers. Messages which contain attachments usually have specific Content-Type values. Thus, to decide which messages to download, you can use the code like below (for brevity, it's assumed the connection with the POP3 server is already established, no error checking, etc):
Code:

Set Msgs = POP3.RetrieveHeaders
For I = 1 To Msgs.Count
  If Msgs(I).HasAttachments Then
    Set Msg = POP3.RetrieveSingleMessage(I)
    If Msg.HasAttachments Then
      ' Process the message here
    End If
  End If
Next


As you can see, we check .HasAttachments property twice. First, when downloading message header only; second, when downloading the entire message. This is because it's possible the message without attachments may still have wrong content-type. Thus, .HasAttachments property is not 100% accurate when only message headers are available. When the entire message was dwonloaded, .HasAttachments property value is determined from the number of attachments (Message.Attachments.Count) and is now 100% accurate.

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