ceyquem
-
4 juin 2000 à 20:20
cs_ShadowMan
Messages postés8Date d'inscriptionvendredi 6 octobre 2000StatutMembreDernière intervention 6 février 2002
-
24 déc. 2001 à 16:53
Bonjour !
Je ne parviens pas à envoyer de mails avec winsowk et le code suivant que j'ai repiqué d'un exemple de vb5 :
*************************************
Public Function SendFormOnNet() As Variant
Dim MailServerName As String
Dim FromName As String
Dim FromEmailAddress As String
Dim ToName As String
Dim ToEmailAddress As String
Dim EmailSubject As String
Dim EmailBodyOfMessage As String
If Winsock1.State <> sckClosed Then
Winsock1.Close
End If
Winsock1.LocalPort = 0 ' Pour pouvoir envoyer plus d'un e-mail par exécution
If Winsock1.State = sckClosed Then ' Vérifie que le port est déjà fermé
DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
first = "mail from :" + Chr(32) + FromEmailAddress + vbCrLf ' Emetteur
Secnd = "rcpt to :" + Chr(32) + ToEmailAddress + vbCrLf ' Destinataire
Third = "Date :" + Chr(32) + DateNow + vbCrLf ' Date d'envoi
Fourth = "From :" + Chr(32) + FromName + vbCrLf ' Nom de l'émetteur
Fifth = "To :" + Chr(32) + ToName + vbCrLf ' Nom du destinataire
Sixth = "Subject :" + Chr(32) + EmailSubject + vbCrLf ' Sujet
Seventh = EmailBodyOfMessage + vbCrLf ' Message
Ninth = "Mail Regitring Wizard 1.0" + vbCrLf ' Programme qui envoie le mail
Eighth = Ninth + Third + Fourth + Fifth + Sixth ' Combine for proper SMTP sending
'Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combine for proper SMTP sending
Winsock1.Protocol = sckTCPProtocol ' Set protocol for sending
Winsock1.RemoteHost = MailServerName ' Set the server address
Winsock1.RemotePort = 25 ' Set the SMTP Port
Winsock1.Connect ' Start connection
WaitFor ("220")
m_Status = "Connection au serveur en cours..."
RaiseEvent StatusChange
Sub WaitFor(ResponseCode As String)
Start = Timer ' Time event so won't get stuck in loop
While Len(lblResponse.Caption) = 0
Tmr = Start - Timer
DoEvents ' Let System keep checking for incoming lblResponse.Caption **IMPORTANT**
If Tmr < -50 Then ' Time in seconds to wait
MsgBox "erreur du serveur SMTP, délai de réponse dépassé", 64, MsgTitle
Exit Sub
End If
While Left(lblResponse.Caption, 3) <> ResponseCode
DoEvents
If Tmr > 50 Then
MsgBox "erreur serveur SMTP, Code invalide, aurait du être : " + ResponseCode + " Code recieved: " + lblResponse.Caption, 64, MsgTitle
Exit Sub
End If
Wend
Wend
lblResponse.Caption = "" ' Sent lblResponse.Caption code to blank **IMPORTANT**
End Sub
*************************************
en fait, la boucle qui attends une réponse tourne 50 sec et dit enfin "délai de réponse dépassé !
*************************************
Merci bcp de votre aide !!!
Certain serveur SMTP n'accepte pas toutes les domain lorsque tu fais un helo.
Parfosi on est obliger de fazire un helo hostduserveurSMTP.
C'est p-e cela, si tu veux verifier va sous telnet.
Bye,
Zimoro
Vous n’avez pas trouvé la réponse que vous recherchez ?
ton code pour les mails est trop long
!
va chercher un plus court et clair
et surtout va faire des essais a la main:
dans dos:
"telnet
exemple: telnet www.caramail.com 25
remarque: avec caramail ca block (troop dangereux)
cs_ShadowMan
Messages postés8Date d'inscriptionvendredi 6 octobre 2000StatutMembreDernière intervention 6 février 2002 24 déc. 2001 à 16:53
Tu te crèves trop avec ton prog... y suffit simplement de faire un winsock1.connect mail.urbanet.ch, 25
puis dans l'événement winsock1_datareceive tu incrémentes une varable de 1, et t'utilises un select case variable qui enverra les données au server étape par étape
Et pour répondre à l'autre qui dit que telnet www.caramail.com, 25 marche pas c normal...
Déjà ce serait pas www. mais mail. ou pop., mais caramail utilise un autre systeme pour ses transferts de mails. G développé un prog qui l'exploite alors si t intéressé contacte moi