Hello,
I am having an issue with sending an email message to multiple recipients on a private SMTP server. Currently, my program sends a message to the first recipient listed, but not the second. I am getting the email addresses from a text box right now that is separated like : email1@blah.com;email2@blah.com. Also, I am using a custom Winsock to send the data right now.
myWinsock.RemoteIP = "127.0.0.1"
myWinsock.RemotePort = 1000
Me.Cursor = Cursors.WaitCursor
lblStatus.Text = "Status: Connecting to server " & txtServer.Text
recips = Split(txtRecipient.Text, ";") 'Split multiple addresses
myWinsock.Connect() 'Connect in form load
Private Sub myWinsock_DataArrival(ByVal sender As SDJWinsock, ByVal BytesTotal As Integer) Handles myWinsock.DataArrival
Dim intReply As Integer
Dim strData As String
Dim strMessage As String
Dim recipCount As Integer = 0
myWinsock.GetData(strData)
intReply = CInt(Microsoft.VisualBasic.Left(strData, 3))
Select Case intReply
Case 220
If Not gblnReceived220 Then
gblnReceived220 = True
gstrCommand = "HELO " & Mid(txtSender.Text, _
InStr(txtSender.Text, "@") + 1) & _
vbCrLf
myWinsock.SendData(gstrCommand)
gstrCommand = Microsoft.VisualBasic.Left(gstrCommand, 4)
End If
Case 250
Select Case gstrCommand
Case "HELO"
gstrCommand = "MAIL FROM: <" &
txtSender.Text & ">" & _
vbCrLf
myWinsock.SendData(gstrCommand)
gstrCommand = Microsoft.VisualBasic.Left(gstrCommand, 4)
Case "MAIL"
gstrCommand = "RCPT TO: <" & recips(recipCount) &
">" & vbCrLf
myWinsock.SendData(gstrCommand)
If recipCount = UBound(recips) Then
gstrCommand = Microsoft.VisualBasic.Left(gstrCommand, 4)
End If
recipCount += 1
Case "RCPT"
gstrCommand = "DATA" & vbCrLf
myWinsock.SendData(gstrCommand)
gstrCommand = Microsoft.VisualBasic.Left(gstrCommand, 4)
Case "DATA"
lblStatus.Text = "Status: Mail was successfuly sent."
Me.Cursor = Cursors.Default
gblnReceived220 = False
Case "QUIT"
lblStatus.Text = "Status: Connection Closed"
myWinsock.Close()
End Select
Case 354
Select Case gstrCommand
Case "DATA"
strMessage = "DATE: " & Format(Now, "f") & vbCrLf & _
"FROM: " & txtSender.Text & vbCrLf & _
"TO: " & txtRecipient.Text & vbCrLf & _
"SUBJECT: " & txtSubject.Text &
vbCrLf & _
vbCrLf & _
txtMessage.Text & vbCrLf & _
vbCrLf & _
"." & vbCrLf
myWinsock.SendData(strMessage)
End Select
I have also tried to loop through, but was unsuccessful too. Any ideas or thoughts on how I can get the message sent to the second recipient?