VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CAccount"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

'code d'erreur
'utilisateur inconnu
Private Const ERROR_NO_SUCH_USER As Long = 1317&
'mot de passe ou nom d'utilisateur incorrect
Private Const ERROR_LOGON_FAILURE As Long = 1326&
'le serveur ne répond pas
Private Const ERROR_SERVER_DISABLED As Long = 1341&
'met en forme un code d'erreur dans une description textuelle
Private Const FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000
Private Declare Function FormatMessage Lib "kernel32.dll" Alias "FormatMessageA" (ByVal dwFlags As Long, ByRef lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, ByRef Arguments As Long) As Long

'crée un nouveau GUID (pour faire un nom de fichier unique)
Private Type Guid
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(0 To 7) As Byte
End Type
Private Declare Sub CoCreateGuid Lib "ole32.dll" (ByRef pguid As Guid)

'variables locales de stockage des valeurs de propriétés
Private mvarPOP3Port As Long 'copie locale
Private mvarPOP3Server As String 'copie locale
Private mvarPOP3Password As String 'copie locale
Private mvarPOP3UserName As String 'copie locale
Private mvarPOP3Secure As Boolean
Private mvarSMTPSecure As Boolean
Private mvarSMTPPassword As String 'copie locale
Private mvarSMTPUserName As String 'copie locale
Private mvardomain As String 'copie locale
Private mvarSMTPPort As Long 'copie locale
Private mvarSMTPServer As String 'copie locale
Private mvarSMTPAUTH As String 'copie locale
Private mvarEmail As String 'copie locale
Private mvarAccountPath As String 'copie locale

'le serveur SMTP
Private WithEvents SMTP As CSMTP
Attribute SMTP.VB_VarHelpID = -1
'le serveur POP3
Private WithEvents POP3 As CPOP3
Attribute POP3.VB_VarHelpID = -1
'les UIDL des mails déjà lus
Private szUIDLList As String
'le fichier de config du compte
Private AccountFile As CINI

Private Declare Function quoted_printable_decode_to_string Lib "MIMECode.dll" Alias "_quoted_printable_decode@8" (ByVal dest As String, ByVal src As String) As Long
Private Declare Function base_64_decode_to_string Lib "MIMECode.dll" Alias "_base_64_decode@8" (ByVal dest As String, ByVal src As String) As Long

'l'évènement de loging des connexions aux serveurs
'=================================================
'szText : texte à logguer
Public Event Logging(ByVal szText As String)

'l'évènement déclenché pour chaque mail lu dans un des dossiers du compte ou à chaque reception d'un mail
'=================================================
'szEnumType   : indique le type de mail
'               -> ToSend   : mail à envoyer
'               -> Sent     : mail envoyé
'               -> Received : mail reçu et/ou non lu
'               -> Read     : mail lu
'szSubject    : indique le sujet du mail
'szTo         : indique le To
'szFrom       : indique le From
'MailDate     : indique la date d'envoi du mail
'bAttachments : indique si le fichier contient des pièces jointes
'szFileName   : nom du fichier EML contenant le mail
Public Event EnumMail(ByVal szEnumType As String, ByVal szTo As String, ByVal szFrom As String, ByVal szSubject As String, ByVal MailDate As String, ByVal bAttachments As Boolean, ByVal szFileName As String, ByVal dwSize As Long)

'==================================================
'méthodes privées
'==================================================

Private Function Demangler(ByVal szMangle As String, Optional szCharset As String) As String
Dim poscharset As Long, posenc As Long, postext As Long, posend As Long
Dim szEnc As String, szEncText As String, szDecText As String, l As Long

poscharset = InStr(szMangle, "=?")
While poscharset
    posenc = InStr(poscharset + 2, szMangle, "?")
    postext = InStr(posenc + 1, szMangle, "?")
    posend = InStr(postext + 1, szMangle, "?=")
    
    szCharset = Mid$(szMangle, poscharset + 2, posenc - poscharset - 2)
    szEnc = Mid$(szMangle, posenc + 1, 1)
    
    szEncText = Mid$(szMangle, postext + 1, posend - postext - 1)
    szDecText = Space(Len(szEncText) + 1)
    If szEnc = "Q" Then
        l = quoted_printable_decode_to_string(szDecText, szEncText)
    ElseIf szEnc = "B" Then
        l = base_64_decode_to_string(szDecText, szEncText)
    End If
    szDecText = Mid$(szDecText, 1, l)
    szMangle = Mid$(szMangle, 1, poscharset - 1) & szDecText & Mid$(szMangle, posend + 2)
    poscharset = InStr(szMangle, "=?")
Wend
Demangler = szMangle
End Function

'traite un fichier EML pour extraire des infos et déclencher l'évènement EnumMail pour avertir le programme principal
'==================================================
'szFile     : nom du fichier EML à traiter
'szEnumType : indique le type de mail
'               -> ToSend   : mail à envoyer
'               -> Sent     : mail envoyé
'               -> Received : mail reçu et/ou non lu
'               -> Read     : mail lu
Private Sub ProcessEML(szFile As String, ByVal szEnumType As String)
Dim szLine As String, buff As String, bDateProcessed As Boolean, bSubjectProcessed As Boolean, bContentProcessed As Boolean, bTo As Boolean, bFrom As Boolean
Dim szDate As String, dt As New CMailDate, iFile As Integer
Dim ct As New CContentType, oldloc As Long, szFrom As String, szTo As String
Dim szSubject As String, su As New CSubject, fr As New from, t As New MailTo
Dim addr As CMailAddress

iFile = FreeFile
Open szFile For Input As #iFile
    Do While Not (EOF(iFile) And bDateProcessed And bSubjectProcessed And bContentProcessed And bTo And bFrom)
        Line Input #iFile, szLine
        szLine = Demangler(szLine)
        If Len(szLine) Then
            Do While Not EOF(iFile)
                oldloc = Seek(iFile)
                Line Input #iFile, buff
                If Len(buff) Then
                    Select Case Asc(Mid$(buff, 1, 1))
                        Case 32, 9 '" ",vbTab
                            szLine = szLine & " " & Trim$(Replace(buff, vbTab, " "))
                        Case Else
                            Seek #iFile, oldloc
                            Exit Do
                    End Select
                Else
                    Seek #iFile, oldloc
                    Exit Do
                End If
            Loop
        Else
            Exit Do
        End If
        If InStr(1, szLine, "Date:", vbTextCompare) = 1 Then
            dt.Parse Mid$(szLine, 7)
            szDate = Str(dt.VBDate)
            bDateProcessed = True
        ElseIf InStr(1, szLine, "Subject:", vbTextCompare) = 1 Then
            su.Parse Mid$(szLine, 10)
            szSubject = su.Subject
            bSubjectProcessed = True
        ElseIf InStr(1, szLine, "Content-Type:", vbTextCompare) = 1 Then
            ct.Parse Mid$(szLine, 15)
            bContentProcessed = True
        ElseIf InStr(1, szLine, "From:", vbTextCompare) = 1 Then
            fr.Parse Mid$(szLine, 6)
            For Each addr In fr
                szFrom = szFrom & "," & addr.Address
            Next
            szFrom = Mid$(szFrom, 2)
            bFrom = True
        ElseIf InStr(1, szLine, "To:", vbTextCompare) = 1 Then
            t.Parse Mid$(szLine, 4)
            For Each addr In t
                szTo = szTo & "," & addr.Address
            Next
            szTo = Mid$(szTo, 2)
            bTo = True
        End If
    Loop
Close #iFile

If (ct.CTType = "multipart") And (ct.CTSubType <> "alternative") Then
    RaiseEvent EnumMail(szEnumType, szTo, szFrom, szSubject, szDate, True, szFile, FileLen(szFile))
Else
    RaiseEvent EnumMail(szEnumType, szTo, szFrom, szSubject, szDate, False, szFile, FileLen(szFile))
End If
End Sub

'charge la liste des UIDLs des mails déjà lus
Private Sub LoadUIDLs()
Dim buff As String, szFileName As String

szFileName = mvarAccountPath & "\UIDLList.uid"
If Len(Dir$(szFileName)) Then
    Open szFileName For Input As #1
        Do While Not EOF(1)
            Line Input #1, buff
            szUIDLList = szUIDLList & ";" & buff & ";"
        Loop
    Close #1
End If
End Sub

'renvoie un nom de fichier EML unique pour un mail
Private Function GenerateUniqueName() As String
Dim g As Guid

CoCreateGuid g

GenerateUniqueName = Hex$(g.Data1) & _
                     Hex$(g.Data2) & _
                     Hex$(g.Data3) & _
                     Hex$(g.Data4(0)) & _
                     Hex$(g.Data4(1)) & _
                     Hex$(g.Data4(2)) & _
                     Hex$(g.Data4(3)) & _
                     Hex$(g.Data4(4)) & _
                     Hex$(g.Data4(5)) & _
                     Hex$(g.Data4(6)) & _
                     Hex$(g.Data4(7)) & ".eml"
End Function

'vérifie si les dossiers du comptes sont biens présents et sinon les crée :
' -> le dossier du compte lui-même (mvarAccountPath)
' -> le dossier des mails à envoyer ("ToSend")
' -> le dossier des mails envoyés ("Sent")
' -> le dossier des mails reçus ("Received")
' -> le dossier des mails lus ("Read")
Private Sub CheckDirs()
If Len(Dir(mvarAccountPath, vbDirectory)) = 0 Then
    MkDir mvarAccountPath
End If

If Len(Dir(mvarAccountPath & "\ToSend", vbDirectory)) = 0 Then
    MkDir mvarAccountPath & "\ToSend"
End If

If Len(Dir(mvarAccountPath & "\Sent", vbDirectory)) = 0 Then
    MkDir mvarAccountPath & "\Sent"
End If

If Len(Dir(mvarAccountPath & "\Received", vbDirectory)) = 0 Then
    MkDir mvarAccountPath & "\Received"
End If

If Len(Dir(mvarAccountPath & "\Read", vbDirectory)) = 0 Then
    MkDir mvarAccountPath & "\Read"
End If

'If Len(Dir(mvarAccountPath & "\Deleted", vbDirectory)) = 0 Then
'    MkDir mvarAccountPath & "\Deleted"
'End If
End Sub

'affiche la fenêtre de demande de mot de passe
'renvoie True si le infos sont OK, False si annulation
Private Function PromptForPassword() As Boolean
    Load frmPrompt
    With frmPrompt
        .txtUser.Text = mvarPOP3UserName
        .txtPass.Text = vbNullString
        .Show vbModal
        PromptForPassword = .Valid
    End With
End Function

'==================================================
'méthodes publiques
'==================================================

'renvoie le message d'erreur textuel correspondant au code errCode
'==================================================
'errCode : code d'erreur à traduire en texte
'renvoie le message d'erreur textuel correspondant au code errCode
Public Function FormatError(ByVal errCode As Long) As String
Dim l As Long
FormatError = Space(256)
l = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, errCode, 0&, FormatError, 256, ByVal 0&)
FormatError = Mid$(FormatError, 1, l)
End Function

'énumère un dossier du compte de mails
'==================================================
'szDir : nom du dossier à énumérer
'               -> "ToSend"   : mail à envoyer
'               -> "Sent"     : mail envoyé
'               -> "Received" : mail reçu et/ou non lu
'               -> "Read"     : mail lu
'renvoie le nombre de mails dans le dossier szDir
Public Function EnumDir(szDir As String) As Long
Dim szFile As String

szFile = Dir$(mvarAccountPath & "\" & szDir & "\*.eml")
Do While Len(szFile)
    ProcessEML mvarAccountPath & "\" & szDir & "\" & szFile, szDir
    EnumDir = EnumDir + 1
    szFile = Dir$
Loop
End Function

'envoie tous les mails du dossier ToSend
'renvoie le nombre de mails envoyés avec succès
Public Function SendAll() As Long
Dim szFile As String, szPath As String, Mail As CMail
Dim szError As String

szFile = Dir$(mvarAccountPath & "\ToSend\*.eml")
szPath = mvarAccountPath & "\ToSend\"
Do While Len(szFile)
    Set Mail = New CMail
    Mail.MailOpen szPath & szFile
    
    If SMTP.SendMail(Mail, szError) = 250 Then
        Name CStr(szPath & szFile) As Replace(szPath & szFile, "\ToSend", "\Sent")
        RaiseEvent Logging("Mail successfully sent !")
    Else
        'RaiseEvent Logging("Failed to send the mail !")
        RaiseEvent Logging(szError)
        SendAll = -1
        Exit Do
    End If
    SendAll = SendAll + 1
    szFile = Dir$
Loop
End Function

'envoie un object mail particulier
'=================================================
'objMail            : mail à envoyer
'szSMTPServerStatus : non utilisé
'renvoie un code d'erreur SMTP (250 = succès,...)
Public Function SendMail(ByVal objMail As CMail, Optional szSMTPServerStatus As String) As Long
    SendMail = SMTP.SendMail(objMail, szSMTPServerStatus)
End Function

'reçoit les nouveaux mails du compte
'renvoie le nombre de mails reçus
Public Function Receive() As Long
Dim ret As Long, nbmail As Long, x As Long, szMailName As String, iMailNum As Integer
Dim iFileUIDLList As Integer, szUIDL As String, bRETR As Boolean, nbnew As Long

'je n'aime pas goto mais la flème
Retry:
If (Len(POP3.Password) = 0) Or (Len(POP3.UserName) = 0) Then
    If PromptForPassword = True Then
        POP3.UserName = frmPrompt.User
        mvarPOP3Password = frmPrompt.Password
        POP3.Password = mvarPOP3Password
    Else
        RaiseEvent Logging("Receiving cancelled by user...")
        Exit Function
    End If
End If

ret = POP3.Connect
If ret Then
    If ret = ERROR_LOGON_FAILURE Then
        RaiseEvent Logging("Mot de passe invalide !")
        MsgBox "Mot de passe invalide !", vbCritical
        POP3.Password = vbNullString
        GoTo Retry
    ElseIf ret = ERROR_NO_SUCH_USER Then
        RaiseEvent Logging("Nom d'utilisateur invalide !")
        POP3.UserName = vbNullString
        GoTo Retry
    Else
        RaiseEvent Logging(POP3.FormatError(ret))
    End If
    Exit Function
End If

nbmail = POP3.GetNumberOfUnreadMail
iFileUIDLList = FreeFile
Open mvarAccountPath & "\UIDLList.uid" For Append As #iFileUIDLList
    For x = 1 To nbmail
        szUIDL = POP3.GetMessageUIDL(x)
        If Len(szUIDL) Then
            bRETR = (InStr(szUIDLList, ";" & szUIDL & ";") = 0)
        Else
            bRETR = False
        End If
        
        If bRETR Then
            nbnew = nbnew + 1
            iMailNum = FreeFile
            szMailName = mvarAccountPath & "\Received\" & GenerateUniqueName
            Open szMailName For Output As #iMailNum
                If POP3.RetrieveMessageAsync(x, iMailNum) = False Then
                    Close #iMailNum
                    Kill szMailName
                    Exit For
                End If
            Close #iMailNum
            ProcessEML szMailName, "Received"
            
            Print #iFileUIDLList, szUIDL
            szUIDLList = szUIDLList & ";" & szUIDL & ";"
        End If
    Next
Close #iFileUIDLList

POP3.Disconnect

RaiseEvent Logging(nbnew & " unread mail !")

Receive = nbnew
End Function

'modifie le fichier de config du compte en fonction des propriétés de l'objet
Public Sub Modify()
AccountFile.FileName = App.Path & "\" & Replace(mvarEmail, "@", "_") & ".acc"

AccountFile.SetValue "POP3", "Server", mvarPOP3Server
AccountFile.SetValue "POP3", "Port", CStr(mvarPOP3Port)
AccountFile.SetValue "POP3", "UserName", mvarPOP3UserName
AccountFile.SetValue "POP3", "Password", mvarPOP3Password
AccountFile.SetValue "POP3", "Secure", CStr(mvarPOP3Secure)

AccountFile.SetValue "SMTP", "UserName", mvarSMTPUserName
AccountFile.SetValue "SMTP", "Password", mvarSMTPPassword
AccountFile.SetValue "SMTP", "Server", mvarSMTPServer
AccountFile.SetValue "SMTP", "Port", CStr(mvarSMTPPort)
AccountFile.SetValue "SMTP", "Domain", mvardomain
AccountFile.SetValue "SMTP", "Secure", CBool(mvarSMTPSecure)

AccountFile.SetValue "Storage", "AccountPath", mvarAccountPath
AccountFile.SetValue "Storage", "Email", mvarEmail
End Sub

'crée un nouveau compte : à utiliser une fois que les propriétés sont renseignée
'renvoie False en cas d'erreur
Public Function Create() As Boolean
If (Len(mvarAccountPath) > 0) And _
   (Len(mvardomain) > 0) And _
   (Len(mvarEmail) > 0) And _
   (Len(mvarPOP3Server) > 0) And _
   (Len(mvarSMTPServer) > 0) And _
   (Len(mvarPOP3UserName) > 0) Then
        MkDir mvarAccountPath
        Modify
        Create = True
End If
End Function

'charge le fichier de config szAccountFile dans les propriétés du compte
Public Sub LoadAccount(szAccountFile As String)
AccountFile.FileName = szAccountFile

POP3Server = AccountFile.GetValue("POP3", "Server")
POP3Port = CLng(AccountFile.GetValue("POP3", "Port"))
POP3UserName = AccountFile.GetValue("POP3", "Username")
POP3Password = AccountFile.GetValue("POP3", "Password")
If Len(AccountFile.GetValue("POP3", "Secure")) Then POP3Secure = AccountFile.GetValue("POP3", "Secure")

SMTPUserName = AccountFile.GetValue("SMTP", "Username")
SMTPPassword = AccountFile.GetValue("SMTP", "Password")
SMTPAUTH = AccountFile.GetValue("SMTP", "AUTH")
SMTPServer = AccountFile.GetValue("SMTP", "Server")
SMTPPort = CLng(AccountFile.GetValue("SMTP", "Port"))
If Len(AccountFile.GetValue("SMTP", "Secure")) Then SMTPSecure = AccountFile.GetValue("SMTP", "Secure")

domain = AccountFile.GetValue("SMTP", "Domain")

mvarEmail = AccountFile.GetValue("Storage", "Email")
If Len(mvarEmail) = 0 Then mvarEmail = mvarPOP3UserName & "@" & mvardomain

mvarAccountPath = AccountFile.GetValue("Storage", "AccountPath")

'InitVars
szUIDLList = vbNullString
LoadUIDLs
CheckDirs
End Sub

'supprime le compte
'===========================================
'Optional bAllData : indique s'il faut supprimer tous les mails du compte
Public Sub Delete(Optional ByVal bAllData As Boolean = False)
Kill AccountFile.FileName

If bAllData Then
    'todo
End If
End Sub

'==================================================
'propriétés
'==================================================

'définit ou renvoie le chemin de stockage des dossiers de mails du compte
Public Property Let AccountPath(ByVal vData As String)
    mvarAccountPath = vData
End Property
Public Property Get AccountPath() As String
    AccountPath = mvarAccountPath
End Property

'définit ou renvoie l'addres Email du compte
Public Property Let Email(ByVal vData As String)
    mvarEmail = vData
End Property
Public Property Get Email() As String
Attribute Email.VB_HelpID = 360
    Email = mvarEmail
End Property

'définit ou renvoie le nom du serveur SMTP du compte
Public Property Let SMTPServer(ByVal vData As String)
Attribute SMTPServer.VB_HelpID = 358
    mvarSMTPServer = vData
    SMTP.SMTPServer = mvarSMTPServer
End Property
Public Property Get SMTPServer() As String
    SMTPServer = mvarSMTPServer
End Property

'définit ou renvoie le nom du serveur SMTP du compte
Public Property Let SMTPAUTH(ByVal vData As String)
    mvarSMTPAUTH = vData
    SMTP.AUTH = mvarSMTPAUTH
End Property
Public Property Get SMTPAUTH() As String
    SMTPAUTH = mvarSMTPAUTH
End Property

'définit ou renvoie le port du serveur SMTP du compte
Public Property Let SMTPPort(ByVal vData As Long)
Attribute SMTPPort.VB_HelpID = 356
    mvarSMTPPort = vData
    SMTP.SMTPPort = mvarSMTPPort
End Property
Public Property Get SMTPPort() As Long
    SMTPPort = mvarSMTPPort
End Property

'définit ou renvoie le domain du compte : la partie après le @ de l'adresse mail
Public Property Let domain(ByVal vData As String)
Attribute domain.VB_HelpID = 354
    mvardomain = vData
    SMTP.domain = mvardomain
End Property
Public Property Get domain() As String
    domain = mvardomain
End Property

'définit ou renvoie le nom d'utilisateur du compte : la partie avant le @ de l'adresse mail
Public Property Let POP3UserName(ByVal vData As String)
Attribute POP3UserName.VB_HelpID = 352
    mvarPOP3UserName = vData
    POP3.UserName = mvarPOP3UserName
End Property
Public Property Get POP3UserName() As String
    POP3UserName = mvarPOP3UserName
End Property

'définit ou renvoie le nom d'utilisateur du compte : la partie avant le @ de l'adresse mail
Public Property Let SMTPUserName(ByVal vData As String)
    mvarSMTPUserName = vData
    SMTP.UserName = mvarSMTPUserName
End Property
Public Property Get SMTPUserName() As String
    SMTPUserName = mvarSMTPUserName
End Property

'définit ou renvoie le nom du serveur POP3 du compte
Public Property Let POP3Server(ByVal vData As String)
Attribute POP3Server.VB_HelpID = 350
    mvarPOP3Server = vData
    POP3.POP3Server = mvarPOP3Server
End Property
Public Property Get POP3Server() As String
    POP3Server = mvarPOP3Server
End Property

'définit ou renvoie le nom du serveur POP3 du compte
Public Property Let POP3Secure(ByVal vData As Boolean)
    mvarPOP3Secure = vData
    POP3.Secure = mvarPOP3Secure
End Property
Public Property Get POP3Secure() As Boolean
    POP3Secure = mvarPOP3Secure
End Property

'définit ou renvoie le nom du serveur POP3 du compte
Public Property Let SMTPSecure(ByVal vData As Boolean)
    mvarSMTPSecure = vData
    SMTP.Secure = mvarSMTPSecure
End Property
Public Property Get SMTPSecure() As Boolean
    SMTPSecure = mvarSMTPSecure
End Property

'définit ou renvoie le port du serveur POP3 du compte
Public Property Let POP3Port(ByVal vData As Long)
Attribute POP3Port.VB_HelpID = 348
    mvarPOP3Port = vData
    POP3.POP3Port = mvarPOP3Port
End Property
Public Property Get POP3Port() As Long
    POP3Port = mvarPOP3Port
End Property

'définit ou renvoie le mot de passe du compte (POP3) : facultatif
Public Property Let POP3Password(ByVal vData As String)
Attribute POP3Password.VB_HelpID = 346
    mvarPOP3Password = vData
    POP3.Password = mvarPOP3Password
End Property
Public Property Get POP3Password() As String
    POP3Password = mvarPOP3Password
End Property

'définit ou renvoie le mot de passe du compte (POP3) : facultatif
Public Property Let SMTPPassword(ByVal vData As String)
    mvarSMTPPassword = vData
    SMTP.Password = mvarSMTPPassword
End Property
Public Property Get SMTPPassword() As String
    SMTPPassword = mvarSMTPPassword
End Property

'==================================================
'évènements internes
'==================================================

'retransmission des evenements de Logging
Private Sub POP3_Logging(ByVal szText As String)
RaiseEvent Logging(szText)
End Sub
Private Sub SMTP_Logging(ByVal szText As String)
RaiseEvent Logging(szText)
End Sub

'évènement de réception d'un mail depuis un serveur POP3
Private Sub POP3_Receive(ByVal szText As String, ByVal cbReceivedSize As Long, ByVal cbMailSize As Long, ByVal lParam As Long)
RaiseEvent Logging("Receiving " & cbReceivedSize & " of " & cbMailSize & " bytes...")
Print #lParam, szText;
DoEvents
End Sub

'==================================================
'constructeur et destructeur
'==================================================
Private Sub Class_Initialize()
mvarAccountPath = App.Path

Set POP3 = New CPOP3
Set SMTP = New CSMTP
Set AccountFile = New CINI
mvarPOP3Port = 110
mvarSMTPPort = 25
End Sub

Private Sub Class_Terminate()
Set AccountFile = Nothing
Set POP3 = Nothing
Set SMTP = Nothing
End Sub
