Attribute VB_Name = "Mail"
Option Explicit

Public Const MAIL_HIGHEST_PRIORITY = 1
Public Const MAIL_HIGH_PRIORITY = 2
Public Const MAIL_NORMAL_PRIORITY = 3
Public Const MAIL_LOW_PRIORITY = 4
Public Const MAIL_LOWEST_PRIORITY = 5

'Action property
Public Const LOG_ON = 1
Public Const LOG_OFF = 2
Public Const LIST_MAIL = 3
Public Const MAIL_STATUS = 4
Public Const GET_UIDL = 5
Public Const CANCEL_REQUEST = 6
Public Const GET_MAIL = 7
Public Const DELETE_MAIL = 8

Public Const SEND_MAIL = 1

'Private Sub PostScores(ByVal PlayerID As Integer)
'    Dim SMTPAddress As String
'    Dim MailError As Boolean
'    Dim DestinationList As String
'    Dim CCList As String
'    Dim Subject As String
'    Dim Message As String
'    '
'    'SMTPAddress = GetAdrs1.GetHostAddress(txtSMTPServer.Text)
'    'SMTPAddress = GetAdrs1.GetHostAddress("smtp.eresmas.com")
'    'If GetAdrs1.ErrorNumber <> 0 Then
'    '    lblSMTPErrorNumber = GetAdrs1.ErrorNumber & " - " & ErrorNumberString(GetAdrs1.ErrorNumber)
'    '    Exit Sub
'    'End If
'    '
'    SMTP1.OriginatingAddress = "squadbot@yahoo.co.uk"
'    SMTP1.OriginatingName = "Squad Warz bot"
'    'SMTP1.HostAddress = SMTPAddress
'    SMTP1.DomainName = "smtp.eresmas.com"
'    SMTP1.MailApplication = "Squad Warz"
'    SMTP1.MailPriority = MAIL_NORMAL_PRIORITY
'    '
'    Subject = "Squad Warz scores"
'    DestinationList = "jgsantos@yahoo.com"
'    Message = "HOLA HOLA COJONES 8888888 UHUHUHUUHHHUUUUUU"
'    '
'    MailError = SMTP1.SendMail(SMTPAddress, Subject, DestinationList, CCList, Message)
'    If MailError Then
'        PrivateMessage PlayerID, "Mail error: " & SMTP1.ErrorNumber & " - " & MailErrorNumberString(SMTP1.ErrorNumber)
'    Else
'        PrivateMessage PlayerID, "Scores has been posted to " & DestinationList
'    End If
'End Sub
'
Public Function MailErrorNumberString(ErrorNumber As Integer)
    ' Translate an error code into something better
    ' suited for human consumption.
    Select Case ErrorNumber
        Case 0:     MailErrorNumberString = "No error."
        Case 4:     MailErrorNumberString = "System level interrupt interrupted socket operation."
        Case 9:     MailErrorNumberString = "Generic error for invalid format (bad format)."
        Case 13:    MailErrorNumberString = "Generic error for access violation."
        Case 14:    MailErrorNumberString = "Generic error for fault."
        Case 22:    MailErrorNumberString = "Generic error for invalid format, entry, etc."
        Case 24:    MailErrorNumberString = "Generic file error."
        Case 25:    MailErrorNumberString = "The IP address provided is not valid or the host specified by the IP address does not exist."
        Case 38:    MailErrorNumberString = "Invalid socket or not connected to remote."
        Case 48:    MailErrorNumberString = "The specified address is already in use."
        Case 49:    MailErrorNumberString = "The specified address is not available."
        Case 50:    MailErrorNumberString = "The connected network is not available."
        Case 51:    MailErrorNumberString = "The connected network is not reachable."
        Case 52:    MailErrorNumberString = "The connected network connection has been reset."
        Case 53:    MailErrorNumberString = "The current connection has been aborted by the network or intermediate services."
        Case 54:    MailErrorNumberString = "The current socket connection has been reset."
        Case 57:    MailErrorNumberString = "The current socket has not been connected."
        Case 58:    MailErrorNumberString = "The connection has been shutdown."
        Case 60:    MailErrorNumberString = "The current connection has timed-out."
        Case 61:    MailErrorNumberString = "The requested connection has been refused by the remote host."
        Case 63:    MailErrorNumberString = "Specified host name is too long."
        Case 64:    MailErrorNumberString = "Remote host is currently unavailable."
        Case 65:    MailErrorNumberString = "Remote host is currently unreachable."
        Case 91:    MailErrorNumberString = "Remote system is not ready."
        Case 92:    MailErrorNumberString = "Current socket version is not supported by the application."
        Case 93:    MailErrorNumberString = "Socket API is not initialized."
        Case 101:   MailErrorNumberString = "Socket has been disconnected."
        Case 110:   MailErrorNumberString = "A restart marker has been received from the remote host."
        Case 120:   MailErrorNumberString = "FTP service will be ready later."
        Case 125:   MailErrorNumberString = "FTP data connection is already open."
        Case 150:   MailErrorNumberString = "FTP file status is OK."
        Case 200:   MailErrorNumberString = "FTP command is OK."
        Case 202:   MailErrorNumberString = "FTP command is not implemented."
        Case 210:   MailErrorNumberString = "No mail connection is available."
        Case 211:   MailErrorNumberString = "Originating e-mail address is invalid."
        Case 212:   MailErrorNumberString = "Destination e-mail address is invalid."
        Case 213:   MailErrorNumberString = "Domain name provided to SMTP is invalid."
        Case 214:   MailErrorNumberString = "Cannot send e-mail data."
        Case 215:   MailErrorNumberString = "Cannot end the transmission of e-mail."
        Case 216:   MailErrorNumberString = "Unable to end the e-mail session."
        Case 217:   MailErrorNumberString = "CC address(es) are invalid."
        Case 220:   MailErrorNumberString = "FTP service is ready for new user."
        Case 221:   MailErrorNumberString = "POP statistics unavailable."
        Case 222:   MailErrorNumberString = "POP e-mail list is unavailable."
        Case 223:   MailErrorNumberString = "Invalid POP account user name."
        Case 224:   MailErrorNumberString = "Invalid POP account user password."
        Case 225:   MailErrorNumberString = "Unable to logoff of POP server."
        Case 226:   MailErrorNumberString = "Unable to delete mail."
        Case 227:   MailErrorNumberString = "Unable to get mail."
        Case 228:   MailErrorNumberString = "Unable to undelete mail."
        Case 229:   MailErrorNumberString = "Unable to retrieve UIDL information."
        Case 230:   MailErrorNumberString = "Unable to log into FTP server."
        Case 250:   MailErrorNumberString = "Requested file action OK, completed."
        Case 257:   MailErrorNumberString = "Path created."
        Case 331:   MailErrorNumberString = "Invalid FTP password."
        Case 332:   MailErrorNumberString = "Invalid FTP account."
        Case 350:   MailErrorNumberString = "File aciton pending further information."
        Case 400:   MailErrorNumberString = "Service disconnected."
        Case 411:   MailErrorNumberString = "No such newsgroup."
        Case 412:   MailErrorNumberString = "No newsgroup selected for operation."
        Case 420:   MailErrorNumberString = "No article has been selected."
        Case 421:   MailErrorNumberString = "No next article available in selected group."
        Case 422:   MailErrorNumberString = "No previous article available in selected group."
        Case 423:   MailErrorNumberString = "No such article available in selected group."
        Case 425:   MailErrorNumberString = "Cannot open data connection."
        Case 426:   MailErrorNumberString = "Connection closed; transfer aborted."
        Case 430:   MailErrorNumberString = "No such article available in selected group."
        Case 435:   MailErrorNumberString = "Article not wanted, do not send to server."
        Case 436:   MailErrorNumberString = "Transfer failed, try again later."
        Case 437:   MailErrorNumberString = "Article rejected, do no resend."
        Case 440:   MailErrorNumberString = "Posting of articles not allowed."
        Case 441:   MailErrorNumberString = "Posting of the article failed."
        Case 450:   MailErrorNumberString = "Requested file action not taken."
        Case 451:   MailErrorNumberString = "Local error in processing."
        Case 452:   MailErrorNumberString = "Insufficient storage space in system."
        Case 500:   MailErrorNumberString = "Syntax error, command unrecognized."
        Case 501:   MailErrorNumberString = "Syntax error in arguments."
        Case 502:   MailErrorNumberString = "Access is restricted or denied."
        Case 503:   MailErrorNumberString = "Program fault, operation not performed."
        Case 504:   MailErrorNumberString = "FTP command not implemented."
        Case 530:   MailErrorNumberString = "Not logged into remote host."
        Case 532:   MailErrorNumberString = "Need account on remote host to store files."
        Case 550:   MailErrorNumberString = "Requested action not taken."
        Case 551:   MailErrorNumberString = "Page type unknown."
        Case 552:   MailErrorNumberString = "Exceeded storage allocation."
        Case 553:   MailErrorNumberString = "File name not allowed."
        Case 926:   MailErrorNumberString = "Local file is invalid."
        Case 927:   MailErrorNumberString = "Local file is invalid."
        Case 1001:  MailErrorNumberString = "Host not found."
        Case 1002:  MailErrorNumberString = "Not authorized, host not found."
        Case 1003:  MailErrorNumberString = "Non-recoverable error."
        Case 1004:  MailErrorNumberString = "No data available for request."
        Case 1010:  MailErrorNumberString = "Query requires an output file."
        Case 1011:  MailErrorNumberString = "Unable to execute application."
        Case 1012:  MailErrorNumberString = "Unable to send data."
        Case 1013:  MailErrorNumberString = "Unable to connect to remote."
        Case 1100:  MailErrorNumberString = "Invalid or unsupported attachment."
        Case 11000: MailErrorNumberString = "Requested operation already being executed.  Retry the request or continue."
        Case Else:  MailErrorNumberString = "Unknown error code."
    End Select
End Function

