Login  
Search All Forums
Dart Home | PowerTCP Mail for ActiveX | Custom Development Reply | PowerTCP Mail for ActiveX Topics | Forums   
AuthorForum: PowerTCP Mail for ActiveX
Topic: IMAP4 Mailbox Retrieve
smanners
simon.manners@soesoft.com

From: Chudleigh, Tasmania, Australia
Posts: 38
Member Since: 04/12/04
posted April 9, 2008 8:03 PM

Hi,

I am using the IMAP4 control to monitor any incoming emails into the "INBOX" of the mail account by setting the "Idle" to true.

When new mail comes in I call "Imap1.Mailboxes("INBOX").Get"

On completion of the Get command I process each email then delete it from the mailbox. What I am trying to do is only read in a maximum of say 10 messages, process those messages then delete. How can I safely stop the message retrieve after a number of messages have been read?

Thanks
Arjun

From: Rome, NY, USA
Posts: 137
Member Since: 09/17/07
posted April 10, 2008 12:37 PM

You may create a counter to keep a track of the messages read so far and check for its value before reading the next message.

The code below shows the same:

Imap1.Mailboxes("Inbox").Get imapGetHeaders
Dim msgs As Messages
Set msgs = Imap1.Mailboxes("Inbox").Messages
Dim msg As Message
Dim nCnt As Long

nCnt = 1

For Each msg In msgs
If nCnt <= 10 Then
'Perform your action
nCnt = nCnt + 1
Else
Exit Sub
End If

Next msg

I hope this helps.
Have a great day.

Regards,
Arjun
smanners
simon.manners@soesoft.com

From: Chudleigh, Tasmania, Australia
Posts: 38
Member Since: 04/12/04
posted April 10, 2008 5:59 PM

Arjun,

Thanks for the reply. Thats not quite what I was trying to do. Say there was some 40,000 messages in the Inbox. I dont want to get all 40,000 headers in one hit then process the message 10 at a time.

What I want to do is get the first 10 message headers, process the messages then delete them. Then process another ten. The problem is if yo get all 40,000 message headers the amount of memory conusumed is quite large. Is there a way to halt the "Imap1.Mailboxes("Inbox").Get imapGetHeaders" after it retrieves the first ten headers?

Thanks
Arjun

From: Rome, NY, USA
Posts: 137
Member Since: 09/17/07
posted April 11, 2008 9:53 AM

Thanks for clarifying the requirement.
Yes, you can limit the number of messages being retrieved by setting the MsgSet parameter of the Get method as shown below:
Imap1.Mailboxes("Inbox").Get imapGetHeaders, "1:10"

The above line of code will get the headers for the first 10 messages.

I hope this helps.

Regards,
Arjun
smanners
simon.manners@soesoft.com

From: Chudleigh, Tasmania, Australia
Posts: 38
Member Since: 04/12/04
posted April 12, 2008 6:17 PM

Perfect, exactly what I was after!

Thanks
Arjun

From: Rome, NY, USA
Posts: 137
Member Since: 09/17/07
posted April 14, 2008 10:22 AM

Thanks for updating.

Regards,
Arjun
Reply | PowerTCP Mail for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX