GrG (Member)
Guru^2
Messaggi: 3430
Iscritto: 21/08/2007
|
Ciao!!
Ho dei problemi con winsock. Io vorrei ke se, ad esempio, premuto un pulsante grazie a winsock viene inviata una e-mail intitolata prova e con scritto ciao a (x esempio) esempio@esempio.it
Grazie in anticipo!!!
p.s. Voglio sapere come inviare e-mail solo con l'oggeto winsock e non con altre cose, come ad esempio utilizzando il programma esterno Outlook
|
|
gantonio (Normal User)
Guru^2
Messaggi: 1532
Iscritto: 09/09/2007
|
Devi contattare il tuo server SMTP ed usare il protocollo omonimo per l'invio.
Dato che non conosci i risvolti del problema e parti da zero, ti dico che non e' una passeggiata ...
Ti consiglio di scaricare e studiare i sorgenti della DLL VbSendMail ... la trovi con google ...
|
|
iGuLy (Ex-Member)
Pro
Messaggi: 66
Iscritto: 17/05/2007
|
Per la sub dell'invio dovresti usare un codice di questo tipo:
Codice sorgente - presumibilmente Delphi |
'sub per l'invio Sub send(Address As String, From As String, Name As String, ToName, Oggetto As String, server As String, messaggio As String) With ws If .State = sckClosed Then DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600" primo = "mail from: " & From & vbCrLf secondo = "rctp to: " & Address & vbCrLf terzo = "Date: " & DateNow & vbCrLf quarto = "From: """ & Name & """ <" & From & ">" + vbCrLf quinto = "To: " & ToNametxt & vbCrLf sesto = "subject: " & Oggetto & vbCrLf settimo = messaggio & vbCrLf NintH = "Mail Sender 1.0 " & vbCrLf .LocalPort = 0 .Protocol = sckTCPProtocol .RemoteHost = server .RemotePort = 25 .Connect WaitFor ("250") txtStato.caption = "Connessione..." .SendData ("HELO iGuLySoft 2007" & vbCrLf) WaitFor ("250") txtStato.caption = "Connesso" WaitFor ("250") txtStato.caption = "Invio in corso" .SendData (primo) WaitFor ("250") .SendData (secondo) WaitFor ("250") .SendData ("data" & vbCrLf) WaitFor ("250") .SendData (quarto & terzo & NintH & quinto & sesto & vbCrLf) .SendData (settimo & vbCrLf) .SendData ("." & vbCrLf) WaitFor ("250") .SendData ("quit" & vbCrLf) txtStato.caption = "Disconnesso" WaitFor ("221") .Close Else MsgBox (Str(.State)) End If End With End Sub
|
Per quella del button:
Codice sorgente - presumibilmente VB.NET |
Private Sub CmdSendMail_Click() send txtDestinatario.Text, txtMittente.Text, txtNome.Text, txtDestinatario.Text, txtOggetto.Text, server.Text, txtMessaggio.Text End Sub
|
Mentre poi dovresti mettere anche una sub per l'attesa:
Codice sorgente - presumibilmente VB.NET |
'sub di attesa e risposta Sub WaitFor(ResponseCode As String) Start = Timer While Len(Response) = 0 Tmr = Start - Timer DoEvents If Tmr > 50 Then ' MsgBox "SMTP service error, timed out while waiting for response", 64, "Error SMTP" Exit Sub End If Wend While Left(Response, 3) <> ResponseCode DoEvents If Tmr > 50 Then MsgBox "SMTP service error, impromper response code. Code should have been: " + ResponseCode + " Code recieved: " + Response, 64, "Error SMTP" Exit Sub End If Wend Response = "" ' End Sub
|
Spero di essere stato chiaro. |
|
GrG (Member)
Guru^2
Messaggi: 3430
Iscritto: 21/08/2007
|
Grazie a tutti e 2 x avermi risposto.
@gatonio: seguirò il tuo consiglio.
@iGuly: grazie x il codice.
Se avrò problemi riposterò.
Ultima modifica effettuata da GrG il 19/09/2007 alle 18:58 |
|
GrG (Member)
Guru^2
Messaggi: 3430
Iscritto: 21/08/2007
|
@gatonio: perdona la mia ignoranza, ma come faccio a contattare il mio server SMTP??
Cmq la dll vbSendMail c'è l'ho.
|
|
gantonio (Normal User)
Guru^2
Messaggi: 1532
Iscritto: 09/09/2007
|
Il server SMTP e' quello fornito dal tuo provider. Lo dovresti avere inserito nella configurazione del tuo client di posta.
@iGuLy
Se vuoi "tradurre" in italiano un programma inglese trovato su internet, almeno fallo completamente ... Ninth=nono
Ultima modifica effettuata da gantonio il 19/09/2007 alle 20:22 |
|
GrG (Member)
Guru^2
Messaggi: 3430
Iscritto: 21/08/2007
|
..:OK:..
|
|
Maffo23 (Ex-Member)
Pro
Messaggi: 63
Iscritto: 14/12/2006
|
Cercate nel sito il programma GhostMail...è ottimo e vi chiarirà tutto
|
|
iGuLy (Ex-Member)
Pro
Messaggi: 66
Iscritto: 17/05/2007
|
guarda che ninth l'ho messo io per abbreviare, l'inglese lo conosco; e poi il primo esempio che mi è capitato l'ho preso.
|
|