Search for unread messages
Dim objIMAP4, objMsg, arrNew, I ' Create IMAP4 object Set objIMAP4 = CreateObject("MailBee.IMAP4") ' Enable logging IMAP4 session into a file objIMAP4.EnableLogging = True objIMAP4.LogFilePath = "C:\Temp\imap4_log.txt" ' Unlock IMAP4 object objIMAP4.LicenseKey = "put your license key here" ' Set IMAP4 server name objIMAP4.ServerName = "mail.server.com" ' Set user credentials objIMAP4.UserName = "username" objIMAP4.Password = "password" ' Connect to the server and ' log in email account If objIMAP4.Connect Then ' Select Inbox folder If objIMAP4.SelectMailbox("Inbox") Then ' Get Unique-IDs of unread messages arrNew = objIMAP4.Search(True, "unseen") If Not objIMAP4.IsError Then ' Loop through new messages For I = LBound(arrNew) To UBound(arrNew) ' Completely retrieve message by its Unique-ID Set objMsg = objIMAP4.RetrieveSingleMessage(arrNew(I), True) If Not objIMAP4.IsError Then ' Display message body MsgBox objMsg.BodyText Else ' Display error information MsgBox "Error #" & objIMAP4.ErrCode & ", " & _ objIMAP4.ErrDesc End If Next Else ' Display error information MsgBox "Error #" & objIMAP4.ErrCode & ", " & _ objIMAP4.ErrDesc End If Else ' Display error information MsgBox "Error #" & objIMAP4.ErrCode MsgBox "Server response: " & objIMAP4.ServerResponse End If ' Close the connection objIMAP4.Disconnect Else ' Display error information MsgBox "Error #" & objIMAP4.ErrCode MsgBox "Server response: " & objIMAP4.ServerResponse End If
<% Dim objIMAP4, objMsg, arrNew, I ' Create IMAP4 object Set objIMAP4 = Server.CreateObject("MailBee.IMAP4") ' Enable logging IMAP4 session into a file objIMAP4.EnableLogging = True objIMAP4.LogFilePath = "C:\Temp\imap4_log.txt" ' Unlock IMAP4 object objIMAP4.LicenseKey = "put your license key here" ' Set IMAP4 server name objIMAP4.ServerName = "mail.server.com" ' Set user credentials objIMAP4.UserName = "username" objIMAP4.Password = "password" ' Connect to the server and ' log in email account If objIMAP4.Connect Then ' Select Inbox folder If objIMAP4.SelectMailbox("Inbox") Then ' Get Unique-IDs of unread messages arrNew = objIMAP4.Search(True, "unseen") If Not objIMAP4.IsError Then ' Loop through new messages For I = LBound(arrNew) To UBound(arrNew) ' Completely retrieve a message by its Unique-ID Set objMsg = objIMAP4.RetrieveSingleMessage(arrNew(I), True) If Not objIMAP4.IsError Then ' Display message body Response.Write objMsg.BodyText & "<br>" Else ' Display error information Response.Write "Error #" & objIMAP4.ErrCode & ", " & _ objIMAP4.ErrDesc & "<br>" End If Next Else ' Display error information Response.Write "Error #" & objIMAP4.ErrCode & ", " & _ objIMAP4.ErrDesc End If Else ' Display error information Response.Write "Error #" & objIMAP4.ErrCode & "<br>" Response.Write "Server response: " & objIMAP4.ServerResponse End If ' Close the connection objIMAP4.Disconnect Else ' Display error information Response.Write "Error #" & objIMAP4.ErrCode & "<br>" Response.Write "Server response: " & objIMAP4.ServerResponse End If %>See Also: