Cant get Mass Email to work from an ASP.NET 2.0 Page

Seems like I did everything right. But I still get this error: Mailbox name not allowed. The server response was: sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)  Below is the code I used.

Protected Sub btnEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        
        Dim conn As OleDbConnection ' This line declares the OLEDb Connection
        Dim cmd As OleDbCommand  ' This line declares the OLEDb Command
        conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=|DataDirectory|\mailing_list.mdb")
        ' This string declares the command string for the email send
        Dim cmdstring As String = "SELECT Email FROM EmailTest"
        
        ' This section assigns the command string and connection to the command declaration
        cmd = New OleDbCommand(cmdstring, conn)
        
        conn.Open() ' This line opens the connection
        Dim myReader As OleDbDataReader ' This line declares the reader and closes the connection
        myReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection) ' This line assigns the command to the reader execute 
        
        Dim msg As MailMessage = New MailMessage()
        Dim MailObj As New SmtpClient("mail.mysite.com")
        Dim sEmail As String
        While myReader.Read()
            
            msg.From = New MailAddress("mysite@mysite.com")
            
            sEmail = myReader("Email")
            msg.To.Add(sEmail)
            msg.Subject = tbSubject.Text
            msg.Body = tbBody.Text
           
            
            MailObj.DeliveryMethod = SmtpDeliveryMethod.Network
       
            'This object stores the authentication values
            Dim basicAuthenticationInfo As New Net.NetworkCredential("mysite@mysite.com", @&#&$&$")
            
            'Put your own, or your ISPs, mail server name on this next line
            MailObj.Host = "mail.mysite.com"
            MailObj.Port = "25"
            MailObj.UseDefaultCredentials = False
            MailObj.Credentials = basicAuthenticationInfo
            MailObj.Send(msg)
       
        End While
              
        lblSubject.Text = "Email Sent!"

    End Sub

Read More

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s