Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Go Back  Xtreme Visual Basic Talk > > > Email multiple recipients using SMTP/Winsock


Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2013, 01:35 PM
regulate regulate is offline
Newcomer
 
Join Date: Feb 2013
Posts: 1
Default Email multiple recipients using SMTP/Winsock


Hello, I am trying to send messages to a private server via winsock/smtp and am successful with 1 recipient, but when I try to send to multiple, the second message does not reach the second recipient.

As of now, I am simply splitting addresses in a text box by a ';' sign and storing them into an array of strings called recips(). I guess I cannot figure out where to loop at. Below is my code:

Code:
        Dim intReply As Integer
        Dim strData As String
        Dim strMessage As String

        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)
                        Else
                            gstrCommand = "MAIL"
                        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"
                        For Each recipient In recips
                            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)
                        Next
                End Select
Any ideas?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
 
Email multiple recipients using SMTP/Winsock
Email multiple recipients using SMTP/Winsock
 
-->