wodPop3Server ActiveX Control - Connected Event
    
 

Description

Fires when user successfully connects to Pop3 server.


Syntax

Private Sub object_Connected(User, Username, Password, Action)



The Connected Event syntax has these parts:

Part Description
object A wodPop3Server object.
User A Pop3User object. Reference to user who wants to login to wodPop3Server.
Username A String value. Represents user's login/username.
Password A String value. Represents user's password. (or hashes value if APOP is used)
Action A Pop3Actions enumeration, as described in settings. Return value you should set to either Allow or Deny to determine if login is successful.

Settings

The settings for Action are:

Constant Value Description
 Deny 0 Deny execution of the action.
 Allow 1 Allow to execute action.

Remarks

Connected event is fired when your application (or you) needs to decide if it will allow user to login or not. For this purpose, user will send his username/ password combination you should check here (from your local database, for instance) and return Allow or Deny constant value using Action argument. By default, Action argument will be set to Deny so if there are any problems with your application, no user is able to login and cause damage to your server.

Typical scenario would be like this:

    If User.Username = "joe" And Password = "joe" Then
        Action = Allow
    Else
        Action = Deny
    End If

Above code is pretty obvious. If username/password combination is joe/joe then user will be able to access his mailbox. If not, he is rejected from the server with error.

Also, important step in this event is that you fill information about user's email properly. For each message that exists on your server, you should add new Message object and provide information about the message. This means you should set up Filename property for each mail message, and sometimes also StartPosition and EndPosition properties also. Typically, you can do it like this:

User.Messages.Add App.Path & "\message.1"

or

Dim msg As Pop3Message
Set msg = User.Messages.Add
msg.FileName = App.Path & "\messages"
msg.StartPosition = 0
msg.EndPosition = 2100

or

Dim msg As Pop3Message
Set msg = User.Messages.Add
msg.Body = "From me " & vbCrLf & "Hello"
 

actually - this last sample is invalid because we don't generate here properly formatted message, but you get the idea - you can create message on the fly. Above code snippets should be done for each message you store for connected user.

IMPORTANT - if EnableAPOP is set to True, then Password property will contain only "APOP" word inside. In that case you must check if password matches by calling TestAPOP method!

You can typically use this method like this (VB code):

Private Sub Pop3_Connected(ByVal User As WODPOP3SERVERCOMLib.IPop3User, ByVal Username As String, ByVal Password As String, Action As WODPOP3SERVERCOMLib.Pop3Actions)

   Action = Deny
   If Password = "APOP" Then
      If Username = "put_username" Then Action = User.TestAPOP("<put_password>")
   Else
      If Username = "<put_username>" And Password = "<put_password>" Then Action = Allow
   End If

   'let's fill mailbox

   .....

End Sub