Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    VB6- socket e mail html

    Spero di non ripetere post precedenti ma dopo una bella ricerca mi sono impantanato....

    ho trovato e riadattato questo codice per inviare mail tramite socket

    codice:
    WaitFor ("220")
    If (networkErr = True) Then GoTo stop_send
    
    porta = socket.LocalPort
    dataTime = "Data " & Format(Date, "Long Date") & " / " & Time
    
    ' Ingresso sul server di posta
    socket.SendData ("HELO" + vbCrLf) ' Saluto il server
    WaitFor ("250")
    If (networkErr = True) Then GoTo stop_send
    
    ' Specifica mittente (controlla relay del server)
    socket.SendData ("MAIL FROM: <" & Txtfrom.Text & ">" + vbCrLf)
    WaitFor ("250")
    If (networkErr = True) Then GoTo stop_send
    
    ' Specifica destinatario
    socket.SendData ("RCPT TO: <" & lstMailing.List(i) & ">" + vbCrLf)
    WaitFor ("250")
    If (networkErr = True) Then GoTo stop_send
    
    ' Corpo dell'e-mail
    socket.SendData ("DATA" + vbCrLf)
    WaitFor ("354")
    If (networkErr = True) Then GoTo stop_send
    
    socket.SendData ("From: """ & txtIntestazione.Text & """ <" & Txtfrom.Text & ">" + vbCrLf)
    socket.SendData ("To: """ & txtNome.Text & """ <" & Txtto.Text & ">" + vbCrLf)
    socket.SendData ("Subject: " & Txtsubject & " " + vbCrLf + vbCrLf)
    
    ' Creo il file di testo per la spedizione
    If Dir(App.Path + "\" + Filename) <> "" Then Kill (App.Path + "\" + Filename)
    Dim fe As Integer
    fe = FreeFile()
    Open App.Path + "\" + Filename For Binary Access Write As fe
        Put fe, , aperturamail & Txtbody.Text & chiusuramail
    Close fe
    
    'Apro il file in lettura e lo invio riga dopo riga
    Dim TextLine
    Open (App.Path + "\" + Filename) For Input As #2
    Do While Not EOF(2)
       Line Input #2, TextLine
       socket.SendData (TextLine + vbCrLf)
    Loop
    Close #2
    
    'socket.SendData ("Local Port: " & porta + vbCrLf + vbCrLf)
    'socket.SendData ("Local HostName: " & socket.LocalHostName + vbCrLf + vbCrLf)
    'socket.SendData ("Local IP: " & socket.LocalIP + vbCrLf + vbCrLf)
    'socket.SendData ("------------------------------------------" + vbCrLf + vbCrLf)
    'socket.SendData (dataTime + vbCrLf + vbCrLf)
    
    If logoFile <> "" And Check1.Value = 1 Then
        If Dir(App.Path + "\" + logoFile) <> "" Then
            UU = ""
             uuEncodeToFile "x.uue", logoFile
            Dim ff As Integer
            ff = FreeFile()
                Open "x.uue" For Input As ff
                Do While Not EOF(ff)
                    Line Input #ff, l
                    socket.SendData l & Chr$(13) & Chr$(10)
                Loop
            Close ff
        End If
    End If
    
    ' Chiudo l'E-mail
    socket.SendData ("." + vbCrLf)
    WaitFor ("250")
    If (networkErr = True) Then GoTo stop_send
    
    socket.SendData ("QUIT" + vbCrLf) ' Chiudo il Socket
    WaitFor ("221")
    socket.Close

    La mail la invia correttamente.....
    il problema è che vorrei impostargli che la mail vada letta come html in quanto il testo della mail è una pagina html che referenzia con immagini ed altro al mio sito....


    qualcuno mi può aiutare?
    if u are junior then Hallo!!!
    if u are senior then Cool!!!
    if u are a lady then Hi baby!!!

    http://www.solamentegratis.it

  2. #2
    Nel Subject mettici il codice HTML che recuperi dal file che ti interessa.
    Ps. qualcuno sa come inviare allegati con Winsock?
    CIAO

  3. #3
    Originariamente inviato da mardok30
    Nel Subject mettici il codice HTML che recuperi dal file che ti interessa.
    if u are junior then Hallo!!!
    if u are senior then Cool!!!
    if u are a lady then Hi baby!!!

    http://www.solamentegratis.it

  4. #4
    Pensavo di essere stato chiaro, ci riprovo:
    socket.SendData ("Subject: " & Txtsubject & " " + vbCrLf + vbCrLf)

    al posto di quel Txtsubject basta che ci metti l'intero codice HTML che ricavi dal file "xxx.html"(puoi farlo leggendo il file html riga per riga e mettere tutto il contenuto in una stringa)
    CIAO, fammi sapere

  5. #5
    Originariamente inviato da mardok30
    Pensavo di essere stato chiaro, ci riprovo:
    socket.SendData ("Subject: " & Txtsubject & " " + vbCrLf + vbCrLf)

    al posto di quel Txtsubject basta che ci metti l'intero codice HTML che ricavi dal file "xxx.html"(puoi farlo leggendo il file html riga per riga e mettere tutto il contenuto in una stringa)
    CIAO, fammi sapere
    ma io lo faccio...solo che quando arriva la mail mi scrive paro paro il codice html e non me lo decodifica.....

    per intenderci credo che serva una cosa del genere:
    codice:
    Const output = "GET / HTTP/1.0" & vbCrLf & _
    "Accept: text/html" & vbCrLf & _
    "Accept-Language: it" & vbCrLf & _
    "User-Agent: Fake-Browser" & vbCrLf & vbCrLf
    socket.SendData (output)
    ovviamente però questo codice non mi funziona...
    if u are junior then Hallo!!!
    if u are senior then Cool!!!
    if u are a lady then Hi baby!!!

    http://www.solamentegratis.it

  6. #6
    Il metodo che ti ho postato funziona se visualizzi la posta nel Browser, ossia se ti colleghi al server di posta usando il Browser, se poi utilizzi Outlook o altro non so aiutarti, forse una soluzione sarebbe quella di trovare un codice funzionante per l'invio di allegati e dovrebbe fare tutto lui.
    Mi dispiace di non esserti stato molto di aiuto.
    CIAO

  7. #7
    Utente di HTML.it
    Registrato dal
    Dec 2004
    Messaggi
    941
    sapete per far funzionare il codice su ...quale oggetto inserire...
    è un componente , un riferimento , file ocx...
    mi par di aver capito che è l' oggetto socket..vero
    grazie a tutti
    domando solo qualcosa di nuovo

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 © 2025 vBulletin Solutions, Inc. All rights reserved.