Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: [VB] Winsock + posta

  1. #1
    Utente di HTML.it L'avatar di Gigi84
    Registrato dal
    May 2001
    Messaggi
    569

    [VB] Winsock + posta

    Ciao tutti!!

    mi serve una info..
    quando mi collego ad un pop per scaricare la posta, su che porta mi risponde lui??v cioè io dove mi devo mettere in attesa??


  2. #2
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212

    Re: [VB] Winsock + posta

    tieni caro...beccati sto sorgente
    Copyright by darkbl00d

    codice:
    Option Explicit
    
    Dim DatiRic As String
    Dim DatiInv As String
    Dim Ric As Boolean
    Dim CONN As Boolean
    
    Private Sub cmdConnetti_Click()
    If Server = "" Then
        MsgBox "Specificare il server SMTP a cui connettersi.", vbInformation, "SMTPClient"
        Server.SetFocus
        Exit Sub
    Else
        fraServer.MousePointer = 13
        fraMitt.MousePointer = 13
        Stato.BackColor = &HFFFF&
        Server.Enabled = False
        Server.BackColor = frmSMTP.BackColor
        cmdConnetti.Enabled = False
        cmdDisconnetti.Enabled = True
        Log = ""
        Connetti
    End If
    End Sub
    
    Private Sub cmdDel_Click()
    If Log = "" Then Exit Sub
    Dim qst As Integer
    qst = MsgBox("Cancellare il log attuale?", vbInformation + vbYesNo, "Confermi?")
    Select Case qst
        Case Is = vbNo
        Case Is = vbYes
            Log = ""
    End Select
    End Sub
    
    Private Sub cmdDisconnetti_Click()
    Disconnetti
    End Sub
    
    Private Sub cmdMessaggio_Click()
    If Mittente = "" Then
        MsgBox "Specificare e-mail del mittente", vbInformation, "Messaggio incompleto"
        Mittente.SetFocus
        Exit Sub
    End If
    If Destinatario = "" Then
        MsgBox "Specificare e-amil del destinatario", vbInformation, "Messaggio incompleto"
        Destinatario.SetFocus
        Exit Sub
    End If
    If Messaggio = "" Then
        MsgBox "Inserire il corpo del messaggio", vbInformation, "Messaggio incompleto"
        Messaggio.SetFocus
        Exit Sub
    End If
    DatiInv = "HELO SMTPClient"
    Winsock.SendData (DatiInv) + vbCrLf
    Log = Log + DatiInv + vbCrLf
    Ric = False
    
    Mittente:
    If Ric = True Then
        DatiInv = "MAIL FROM: " & Trim(Mittente)
        Winsock.SendData (DatiInv) + vbCrLf
        Log = Log + DatiInv + vbCrLf
        Ric = False
        GoTo Destinatario
    Else
        DoEvents
        GoTo Mittente
    End If
    
    Destinatario:
    If Ric = True Then
        DatiInv = "RCPT TO: " & Trim(Destinatario)
        Winsock.SendData (DatiInv) + vbCrLf
        Log = Log + DatiInv + vbCrLf
        Ric = False
        GoTo Check
    Else
        DoEvents
        GoTo Destinatario
    End If
    
    Check:
    If Ric = True Then
        DatiInv = "DATA"
        Winsock.SendData (DatiInv) + vbCrLf
        Log = Log + DatiInv + vbCrLf
        Ric = False
        GoTo Messaggio:
    Else
        DoEvents
        GoTo Check
    End If
    
    Messaggio:
    If Ric = True Then
        DatiInv = Messaggio
        Winsock.SendData (DatiInv) + vbCrLf + vbCrLf
        Log = Log + DatiInv + vbCrLf
        Ric = False
        GoTo Chiudi
    Else
        DoEvents
        GoTo Messaggio
    End If
    
    Chiudi:
    DatiInv = "."
    Winsock.SendData (DatiInv) + vbCrLf
    Log = Log + DatiInv + vbCrLf
    Ric = False
    
    Verifica:
    If Ric = True Then
        MsgBox "     Operazione completata." & Chr(13) & Chr(13) & _
               " Verificare il log per accertarsi" & Chr(13) & _
               "che tutto sia andato a buon fine.", vbInformation, "Ok"
        Ric = False
        Disconnetti
        Exit Sub
    Else
        DoEvents
        GoTo Verifica
    End If
    End Sub
    
    Private Sub cmdSave_Click()
    If Log = "" Then Exit Sub
    On Error GoTo NoLog
    CD.ShowSave
    Dim nFile As Integer
    nFile = FreeFile
    Open CD.FileName For Append As #nFile
    Print #nFile, "---------------------------"
    Print #nFile, Now
    Print #nFile, Chr(13)
    Print #nFile, Server
    Print #nFile, Chr(13)
    Print #nFile, Log
    Print #nFile, Chr(13)
    Print #nFile, "-----------------------------"
    Close #nFile
    Exit Sub
    NoLog:
    End Sub
    
    Private Sub Destinatario_Change()
    If CONN = True Then
        If Mittente = "" Or Destinatario = "" Or Messaggio = "" Then
            cmdMessaggio.Enabled = False
        Else
            cmdMessaggio.Enabled = True
        End If
    Else
        cmdMessaggio.Enabled = False
    End If
    End Sub
    
    Private Sub Form_Load()
    Me.Height = 4620
    Me.Width = 5775
    Server.Enabled = True
    cmdConnetti.Enabled = True
    cmdDisconnetti.Enabled = False
    cmdMessaggio.Enabled = False
    cmdMessaggio.Enabled = False
    Stato.BackColor = &HFF&
    CONN = False
    End Sub
    
    Private Sub Form_Resize()
    On Error Resume Next
    Me.Height = 4620
    Me.Width = 5775
    End Sub
    
    Private Sub Messaggio_Change()
    If CONN = True Then
        If Mittente = "" Or Destinatario = "" Or Messaggio = "" Then
            cmdMessaggio.Enabled = False
        Else
            cmdMessaggio.Enabled = True
        End If
    Else
        cmdMessaggio.Enabled = False
    End If
    End Sub
    
    Private Sub Mittente_Change()
    If CONN = True Then
        If Mittente = "" Or Destinatario = "" Or Messaggio = "" Then
            cmdMessaggio.Enabled = False
        Else
            cmdMessaggio.Enabled = True
        End If
    Else
        cmdMessaggio.Enabled = False
    End If
    End Sub
    
    Private Sub Mittente_GotFocus()
    If CONN = True Then
        If Mittente = "" Or Destinatario = "" Or Messaggio = "" Then
            cmdMessaggio.Enabled = False
        Else
            cmdMessaggio.Enabled = True
        End If
    Else
        cmdMessaggio.Enabled = False
    End If
    End Sub
    
    Sub Msg_On()
    Mittente.Enabled = True
    Destinatario.Enabled = True
    Messaggio.Enabled = True
    End Sub
    
    Sub Msg_Off()
    Mittente.Enabled = False
    Destinatario.Enabled = False
    Messaggio.Enabled = False
    End Sub
    
    Sub Cancella_Campi_Msg()
    Mittente = ""
    Destinatario = ""
    Messaggio = ""
    End Sub
    
    Sub Connetti()
    Winsock.RemoteHost = Trim(Server)
    Winsock.RemotePort = 25
    Winsock.Connect
    End Sub
    
    Sub Disconnetti()
    Winsock.Close
    fraServer.MousePointer = 0
    fraMitt.MousePointer = 0
    Stato.BackColor = &HFF&
    Server.Enabled = True
    Server.SelStart = 0
    Server.SelLength = Len(Server)
    Server.SetFocus
    Server.BackColor = &HB99568
    cmdConnetti.Enabled = True
    cmdDisconnetti.Enabled = False
    cmdMessaggio.Enabled = False
    Cancella_Campi_Msg
    CONN = False
    End Sub
    
    Private Sub Winsock_Connect()
    CONN = True
    fraServer.MousePointer = 0
    fraMitt.MousePointer = 0
    Stato.BackColor = &HFF00&
    Server.Enabled = False
    Msg_On
    Mittente.SetFocus
    End Sub
    
    Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    Winsock.GetData DatiRic
    Log = Log + DatiRic + vbCrLf
    Ric = True
    End Sub
    
    Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    fraServer.MousePointer = 0
    MsgBox "Impossibile collegarsi al server " & Trim(Server), vbExclamation, "Errore"
    Disconnetti
    End Sub

  3. #3
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212
    è vecchio...l'ho fatto 2 anni fa...quindi ci saranno parti di codice da ottimizzare. Il lavoro non ti mancherà di certo, spero possa servirti. E spero serva anche a qualcun'altro.

  4. #4
    Utente di HTML.it L'avatar di Gigi84
    Registrato dal
    May 2001
    Messaggi
    569
    ok grazie..
    prometto che lo terrò con con cura..!!

    ma allora non bisogna fare winsock.liste da nessuna parte??


  5. #5
    Utente di HTML.it L'avatar di Gigi84
    Registrato dal
    May 2001
    Messaggi
    569
    non riesco a farmi generare l'evento dataarrival..

    quando mi connetto (e mi connetto) lui dovrebbe rispondermi con una cosa del tipo
    +OK POP3 PROXY server ready (6.5.001) <xxx@pop3.libero.it>

    invece no!!! non mi genera l'evento!!


  6. #6
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212
    Originariamente inviato da Gigi84
    non riesco a farmi generare l'evento dataarrival..

    quando mi connetto (e mi connetto) lui dovrebbe rispondermi con una cosa del tipo
    +OK POP3 PROXY server ready (6.5.001) <xxx@pop3.libero.it>

    invece no!!! non mi genera l'evento!!

    :master: bisogna vedere cosa fa il server....questo listato aspetta finchè i lserver non risponde.

    Prova a collegarti con il telnet di win e vedi se il server risponde ai comandi.


  7. #7
    Utente di HTML.it L'avatar di Gigi84
    Registrato dal
    May 2001
    Messaggi
    569
    ho provato e il server mi dovrebbe rispondere quello che ho detto prima solo che non mi genera l'evento dataarrival..

    anzi.. a volte si (1 volta) e a volte no (tutte le altre..)

    :master:

  8. #8
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212
    uhmmm l'ho detto che ci sarebbe stato da lavorare...cmq il prog serve per inviare la posta, infatti si collega alla porta 25.

    Se tu vuoi leggere devi modificare le procedure.

    Cmq mi sembra strano il comportamento...forse è una questione di velocità di risposta (troppo veloce per il prog o troppo lento)

    Fai delle prove....mi dispiace

  9. #9
    Utente di HTML.it L'avatar di Gigi84
    Registrato dal
    May 2001
    Messaggi
    569
    no.. ok.. sono cretino.. (..ma và?!)

    avevo fatto un errore cretino.. chew è meglio che non vi dico altrimenti mt toccherebbe autobannarmi...

  10. #10
    Utente di HTML.it L'avatar di darkblOOd
    Registrato dal
    Jul 2001
    Messaggi
    2,212
    Originariamente inviato da Gigi84
    no.. ok.. sono cretino.. (..ma và?!)

    avevo fatto un errore cretino.. chew è meglio che non vi dico altrimenti mt toccherebbe autobannarmi...


    mi hai fatto preoccupare....o detto "che figura di merda....gli ho postato il codice che non va"

    :gren:

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.