Search The ForumSearch   RegisterRegister  LoginLogin

MailBee IMAP4

 AfterLogic Forum : MailBee IMAP4
Subject Topic: list new messages first !! Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
XAvinashX
Newbie
Newbie


Joined: 17 April 2007
Location: United States
Online Status: Offline
Posts: 7
Posted: 06 June 2007 at 6:25pm | IP Logged Quote XAvinashX

i havent been able to solve this problem yet. please can someone help me with a sample script to show me how to retrive new messages first then the later ones...

plz plz

i tried using this but it still shows the later messages first then the new ones..

<%
Dim objIMAP4, objMsg, arrNew, I
Set objIMAP4 = Server.CreateObject("MailBee.IMAP4")
objIMAP4.LicenseKey = "xxxxxxxxx"
objIMAP4.ServerName = "xxxxx.com"
objIMAP4.UserName = "xxxx"
objIMAP4.Password = "xxxx"

If objIMAP4.Connect Then

objIMAP4.SelectMailbox "xxxx"

arrNew = objIMAP4.Search(True, "new")
    
For I = LBound(arrNew) To UBound(arrNew)

Unique-ID
    Set objMsg = objIMAP4.RetrieveSingleMessage(arrNew(I), True)

    Response.Write _
      "From: " & Server.HTMLEncode(objMsg.FromAddr) & "<br>" & _
      "To: " & Server.HTMLEncode(objMsg.ToAddr) & "<br>" & _
      "Subject: " & Server.HTMLEncode(objMsg.Subject) & "<br>" & _
      "Date: " & objMsg.GetDateFromString(objMsg.Date) & "<br><br>" & _
      objMsg.BodyText
Next

objIMAP4.Disconnect
End If
%>
Back to Top View XAvinashX's Profile Search for other posts by XAvinashX
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 07 June 2007 at 12:08am | IP Logged Quote Andrew

"NEW" is a combination of "UNSEEN" and "RECENT" flags. If you connect to a mailbox in read/write mode where some messages have "RECENT" flag set, download no messages, and then disconnect from the mailbox, "RECENT" flag will be reset for all the messages. Instead of "NEW", please try to use "UNSEEN" flag which is reset once the message gets downloaded.

Try to replace the following line of your code:

Code:
arrNew = objIMAP4.Search(True, "new")


with:

Code:
arrNew = objIMAP4.Search(True, "UNSEEN")



Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
XAvinashX
Newbie
Newbie


Joined: 17 April 2007
Location: United States
Online Status: Offline
Posts: 7
Posted: 07 June 2007 at 8:15pm | IP Logged Quote XAvinashX

i tried using "UNSEEN", it dosent show any messages. it only shows me the messages if i use "all"
Back to Top View XAvinashX's Profile Search for other posts by XAvinashX
 
XAvinashX
Newbie
Newbie


Joined: 17 April 2007
Location: United States
Online Status: Offline
Posts: 7
Posted: 07 June 2007 at 8:16pm | IP Logged Quote XAvinashX

XAvinashX wrote:
i tried using "UNSEEN", it dosent show any messages. it only shows me the messages if i use "all"
Back to Top View XAvinashX's Profile Search for other posts by XAvinashX
 
XAvinashX
Newbie
Newbie


Joined: 17 April 2007
Location: United States
Online Status: Offline
Posts: 7
Posted: 07 June 2007 at 8:22pm | IP Logged Quote XAvinashX

this is my actual code that i am using.
please if you can modify this and show me how i can list new messages first.

<%
Dim objIMAP4, objEnvelopes, arrUIDs, objMsg, myDate, myString
Set objIMAP4 = CreateObject("MailBee.IMAP4")
objIMAP4.LicenseKey = "xxxx"
objIMAP4.ServerName = "xxxx"
objIMAP4.UserName = "xxxx"
objIMAP4.Password = "xxxx"
If objIMAP4.Connect Then
If objIMAP4.SelectMailbox("xxxx") Then
arrUIDs = objIMAP4.Search(True)
Set objEnvelopes = objIMAP4.RetrieveEnvelopes(1, objIMAP4.MessageCount, False)
SetLocale("en-us")
Set Msg = CreateObject("MailBee.Message")
%>
<%
For I = 1 To objEnvelopes.Count
myDate = msg.GetDateFromString(objEnvelopes(I).Date, False)
myString = FormatDateTime(myDate, 2)
%>
<%= objEnvelopes(I).FromAddr %>
<a href="ee.asp?uid=<%= arrUIDs(I) %>"><%= objEnvelopes(I).Subject %></a>
<%= myString %>
<%
Next
End If
End If
%>
<%
objIMAP4.Disconnect
objEnvelopes.Disconnect
Msg.Disconnect
%>
Back to Top View XAvinashX's Profile Search for other posts by XAvinashX
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 07 June 2007 at 11:21pm | IP Logged Quote Andrew

We tested the following sample with our IMAP server:

Code:
<%
Dim objIMAP4, objMsg, arrNew, I
Set objIMAP4 = Server.CreateObject("MailBee.IMAP4")
objIMAP4.LicenseKey = "xxxxxxxxx"
objIMAP4.ServerName = "xxxxx.com"
objIMAP4.UserName = "xxxx"
objIMAP4.Password = "xxxx"

If objIMAP4.Connect Then

objIMAP4.SelectMailbox "xxxx"

arrNew = objIMAP4.Search(True, "Unseen")
    
For I = LBound(arrNew) To UBound(arrNew)

Unique-ID
    Set objMsg = objIMAP4.RetrieveSingleMessage(arrNew(I), True)

    Response.Write _
      "From: " & Server.HTMLEncode(objMsg.FromAddr) & "<br>" & _
      "To: " & Server.HTMLEncode(objMsg.ToAddr) & "<br>" & _
      "Subject: " & Server.HTMLEncode(objMsg.Subject) & "<br>" & _
      "Date: " & objMsg.GetDateFromString(objMsg.Date) & "<br><br>" & _
      objMsg.BodyText
Next

objIMAP4.Disconnect
End If
%>


And found it works fine, i.e. shows only new messages which have not been downloaded yet.

We executed this sample first time, it displayed no messages because Inbox had no new messages. Then, we sent a couple of messages to the test account and executed the sample again, it displayed these new messages only. Third execution displayed no messages because Inbox had no new messages again.

In the actual code you provided, you're downloading all messages, not new:

Code:
Set objEnvelopes = objIMAP4.RetrieveEnvelopes(1, objIMAP4.MessageCount, False)


The following lines are incorrect and unnecessary:

Code:
objEnvelopes.Disconnect
Msg.Disconnect



Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

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