Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Loop through all available emails Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Tom B.
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 28 January 2005 at 8:04pm | IP Logged Quote Tom B.

Hello,

I'm trying to loop through all emails and get the details of each email (From, Subject, Date and full body)
using ASP.NET (VB). Do you have an example how to do that ? Thanks in advance.
Back to Top View Tom B.'s Profile Search for other posts by Tom B.
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 29 January 2005 at 4:37am | IP Logged Quote Alex

There is POP3 sample project for ASP.NET in MailBee Programming Samples menu of MailBee group in Programs menu. Also, there is a number of ASP samples there (the code for them is nearly the same as for ASP.NET). These samples cover different aspects of mail receiving.

Also, in your particular case, you can start with the code like below:

Code:

Dim oMailer As Object, oMsgs As Object, oMsg As Object

oMailer = Server.CreateObject("MailBee.POP3")

' Log file allows you to debug more easily
oMailer.LogFilePath = "C:\pop3_log.txt"
oMailer.EnableLogging = True

oMailer.LicenseKey = "License Key"
oMailer.ServerName = "mail.server.com"
oMailer.UserName = "user"
oMailer.Password = "pass"

oMsgs = oMailer.RetrieveMessages()

If IsNothing(oMsgs) Then
  Response.Write "Error, see log"
Else
  For Each oMsg In oMsgs
    Response.Write "From: " & oMsg.PureFromAddr & "<br>"
    Response.Write "To: " & oMsg.PureToAddr & "<br>"
    Response.Write "Subject: " & oMsg.Subject & "<br>"
    Response.Write "Date: " & oMsg.Date & "<br>"
    Response.Write "Body:<br>" & oMsg.BodyText & "<br>====<br>"
  Next
End If

oMailer.Disconnect()


Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Tom B.
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 29 January 2005 at 10:11am | IP Logged Quote Tom B.

Thanks a lot Alex, that was what I was looking for.
Back to Top View Tom B.'s Profile Search for other posts by Tom B.
 
small fix
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 03 June 2006 at 12:17am | IP Logged Quote small fix

Well I had problem with the code above if someone uses ASP IIS 6.0 here is the correction
==========

<%
Dim oMailer, oMsg, oAttach
Dim I, nMessageNumber

set oMailer = Server.CreateObject("MailBee.POP3")

' Log file allows you to debug more easily
oMailer.LogFilePath = "C:\pop3_log.txt"
oMailer.EnableLogging = True

oMailer.LicenseKey = "MBC****"
oMailer.ServerName = "mail.server.com"
oMailer.UserName = "user"
oMailer.Password = "pass"

set oMsgs = oMailer.RetrieveMessages()

If Isnull(oMsgs) Then
Response.Write "Error, see log"
Else
For Each oMsg In oMsgs
    Response.Write "From: " & oMsg.PureFromAddr & "<br>"
    Response.Write "To: " & oMsg.PureToAddr & "<br>"
    Response.Write "Subject: " & oMsg.Subject & "<br>"
    Response.Write "Date: " & oMsg.Date & "<br>"
    Response.Write "Body:<br>" & oMsg.BodyText & "<br>====<br>"
Next
End If
oMailer.Disconnect()
%>
======
Back to Top View small fix's Profile Search for other posts by small fix
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 03 June 2006 at 8:00am | IP Logged Quote Alex

Thank you for the note. IsNothing function is actually missing in ASP (it was introduced in VB.NET/ASP.NET).

However, it's not correct to replace it with IsNull since Nothing and Null are different values and POP3.RetrieveMessages method never returns Null. To check for Nothing in classic ASP, it's better to use:
Code:

If oMsgs Is Nothing Then

Another difference between classic and .NET ASP version is "Set" statement (such as in "Set oMailer = Server.CreateObject..." declaration). It's required in classic ASP/VB, while it's no longer used in .NET.

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