Bonjour à tous,
Voici mon probleme: J'utilise winsock pour envoyer des mails via une interface developpée en VB6, cela marche quand j'utilise certains des serveurs mail, mais il y a un des serveurs avec lequel je rencontre des problemes.
La premiere question est de savoir comment tracer chaque etape du processus winsock .
La deuxieme question est de savoir comment recuperer le type d'erreur que je rencontre.
Il faut savoir que j'utilise des serveurs EXCHANGE pour envoyer mes mails et que les serveurs sont eparpaillés dans differents pays.
Exemple : j'utilise 3 serveurs qui se trouvent tous 3 à londres. Pour 2 d'entre cela marche tres bien mais pour le 3 eme j'ai un probleme.
Ma 3eme et derniere question : Quelqu'un saurait il d'ou peu venir le probleme.
voici la fonction que j'utilise pour en envoyer le Mail (On sait tous ici qu'il s'agit d'un envoie en SMTP) :
Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)
Dim 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
With Winsock1
.Close
If .State = sckClosed Then ' Check to see if socket is closed
DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
first = "mail from: " & FromEmailAddress & vbCrLf ' Get who's sending E-Mail address
Second = "rcpt to: " & ToEmailAddress & vbCrLf ' Get who mail is going to
'Third = "Date: " & DateNow & vbCrLf ' Date when being sent
Fourth = "From: """ & FromName & """ <" & FromEmailAddress & ">" + vbCrLf ' Who's Sending
Fifth = "To: " & ToName & vbCrLf ' Who it going to
Sixth = "Subject: " & EmailSubject & vbCrLf ' Subject of E-Mail
Seventh = EmailBodyOfMessage & vbCrLf ' E-mail message body
Ninth = "X-Mailer: Monster HelpDesk" & vbCrLf ' What program sent the e-mail, customize this
.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail per program start
.Protocol = sckTCPProtocol ' Set protocol for sending
.RemoteHost = MailServerName ' Set the server address
.RemotePort = 25 ' Set the SMTP Port
.Connect ' Start connection
WaitFor ("220")
statustxt.Caption = "Connecting...."
.SendData ("HELO EnterComputerNameHere" & vbCrLf)
WaitFor ("250")
statustxt.Caption = "Connected"
.SendData (first)
statustxt.Caption = "Sending Message"
WaitFor ("250")
.SendData (Second)
WaitFor ("250")
.SendData ("data" & vbCrLf)
WaitFor ("354")
.SendData (Fourth & Third & Ninth & Fifth & Sixth & vbCrLf)
.SendData (Seventh & vbCrLf)
.SendData ("." & vbCrLf)
WaitFor ("250")
.SendData ("quit" & vbCrLf)
statustxt.Caption = "Disconnecting"
WaitFor ("221")
.Close
Else
MsgBox (str(.State))
End If
End With
End Sub
Votre aide me serai tres precieuse.
Par avance merci.
C


L