Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Invio Mail

  1. #1
    Utente di HTML.it L'avatar di skiz
    Registrato dal
    Apr 2003
    Messaggi
    14

    Invio Mail

    devo fare un programmino per inviare delle mail,
    ma non sò se c'è qualche oggetto già fatto per l'invio.

    Sapreste darmi qualche consiglio????:gren:

  2. #2
    non so se ti può aiutare ma nella directory

    "c:\Programmi\Microsoft Visual Studio\MSDN98\98VS\1040\SAMPLES\VB98\misc\vbmail"
    c'è un esempio su come fare un programma di posta

  3. #3
    io un po di tempo fa avevo usato questo codice, non mi ricordo se l'avevo modificato...comunque dovrebbe funzionare. L'unico inconveniente è che non permette di spedire gli allegati.

    -------------------------------------------------------------

    Dim Response As String, Reply As Integer, DateNow As String
    Dim first As String, Second As String, Third As String
    Dim Fourth As String, Fifth As String, Sixth As String
    Dim Seventh As String, Eighth As String
    Dim Start As Single, Tmr As Single

    Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)


    Winsock1.LocalPort = 0 ' Setta la porta locale a zero

    If Winsock1.State = sckClosed Then ' Verifica che il socket sia chiuso
    DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
    first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf ' Indirizzo E-Mail inviante
    Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf ' e-mail ricevente
    Third = "Date:" + Chr(32) + DateNow + vbCrLf ' Data di invio
    Fourth = "From:" + Chr(32) + FromName + vbCrLf ' Inviante
    Fifth = "To:" + Chr(32) + ToNametxt + vbCrLf ' Ricevente
    Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf ' Soggetto E-mail
    Seventh = EmailBodyOfMessage + vbCrLf ' Messaggio E-mail
    Ninth = "E-Mailer: Mauro Reporter v 1.x" + vbCrLf ' Programma che invia l'e-mail, personalizzabile
    Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combina l' SMTP inviante
    Winsock1.protocol = sckTCPProtocol ' Setta il protocollo per l'invio
    Winsock1.RemoteHost = MailServerName ' Setta l'indirizzo del server
    Winsock1.RemotePort = 25 ' Setta la porta SMTP
    Winsock1.Connect ' Avvia la connessione
    WaitFor ("220")
    StatusTxt.Caption = "Connessione in corso...."
    StatusTxt.Refresh
    Winsock1.SendData ("HELO worldcomputers.com" + vbCrLf)
    WaitFor ("250")
    StatusTxt.Caption = "Connessione in corso"
    StatusTxt.Refresh
    Winsock1.SendData (first)
    StatusTxt.Caption = "Sto inviando il messaggio"
    StatusTxt.Refresh
    WaitFor ("250")
    Winsock1.SendData (Second)
    WaitFor ("250")
    Winsock1.SendData ("data" + vbCrLf)
    WaitFor ("354")
    Winsock1.SendData (Eighth + vbCrLf)
    Winsock1.SendData (Seventh + vbCrLf)
    Winsock1.SendData ("." + vbCrLf)
    WaitFor ("250")
    Winsock1.SendData ("quit" + vbCrLf)
    StatusTxt.Caption = "Disconnessione in corso"
    StatusTxt.Refresh
    WaitFor ("221")
    Winsock1.Close
    Else
    MsgBox (Str(Winsock1.State))
    End If
    End Sub


    Sub WaitFor(ResponseCode As String)

    Start = Timer
    While Len(Response) = 0
    Tmr = Start - Timer
    DoEvents
    If Tmr > 50 Then ' Tempo in secondi di attesa
    MsgBox "Errore SMTP, tempo di attesa scaduto", 64, MsgTitle
    Exit Sub
    End If
    Wend

    While Left(Response, 3) <> ResponseCode
    DoEvents
    If Tmr > 50 Then
    MsgBox "Errore SMTP, codice di risposta improprio. Codice: " + ResponseCode + " Codice ricevuto: " + Response, 64, MsgTitle
    Exit Sub
    End If
    Wend
    Response = "" ' Invia il codice di risposta in bianco
    End Sub
    Private Sub Command1_Click()
    Command1.Enabled = False
    SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text
    StatusTxt.Caption = "IcoNav 1.0"
    StatusTxt.Refresh

    Close
    Command1.Enabled = True
    End Sub
    Private Sub Command2_Click()
    Form3.Enabled = False
    Form3.Hide
    Form1.Enabled = True
    End Sub


    Private Sub txtFromEmailAddress_Change()

    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Winsock1.GetData Response ' Verifica le risposte
    End Sub

    ------------------------------------------------------------------

    questo è il form:
    Immagini allegate Immagini allegate
    Il tasto RESET non tradisce mai....

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.