wodPop3Server ActiveX Control - Connected Method
      
 

Description

Called when user successfully connects to Pop3 server.


Return Type

None  


Syntax

object.Connected Owner, User, Username, Password, Action



The Connected Method syntax has these parts:

Part Description
object An expression evaluating to an object of type wodPop3Notify.
Owner  A wodPop3ServerCom object. Reference to wodPop3ServerCom instance that called this callback method.
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. It can also hold APOP digest of the password.
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

NOTE: This method is called only if you implemented IwodPop3Notify interface in your application, and wodPop3Server1.Notification property has received reference to instance of your implementation.

Connected notification method is called 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 notification 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 IwodPop3Notify_Connected(ByVal Owner As WODPOP3SERVERCOMLib.IwodPop3ServerCom, 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