chefytim Posted June 4, 2003 Posted June 4, 2003 I have a database with a table called "members" with five fields in it called MemberID, Husband, Wife, HEmail and WEmail. I am wanting to be able to send an email from a web form to all the people in table using VB.NET including HEmail and WEmail. The web form will include a Subject and Information field. I am trying to do this without using a third party application like AspEmail so I am not bound to any particular web host. Can someone help me with this? Thanks, Tim Quote
*Experts* mutant Posted June 4, 2003 *Experts* Posted June 4, 2003 Look into this class: System.Web.Mail.SmtpMail Its small and pretty selfexplanatory :) But you will need an SMTP service running on your server. Quote
Madz Posted June 4, 2003 Posted June 4, 2003 From IIS Admin you can configure your SMTP Servre. and then with this class System.Web.Mail.SMTP you can send emails. Quote The one and only Dr. Madz eee-m@il
chefytim Posted June 4, 2003 Author Posted June 4, 2003 Well, not being too good at coding VB.NET I really am looking for some example code that will extract the emails from the datbase and then send the form field values to the list of emails. Thanks for the help Quote
*Experts* mutant Posted June 4, 2003 *Experts* Posted June 4, 2003 First you have to connect to the database... Dim Conn as new SqlConnection("you connection string goes here")'or OleDBConnection if you use Access or something else Dim Cmd as New SqlCommand("SELECT email FROM users", Conn) 'lets assume your email field is called email and your table is called users Dim reader as SqlDataReader Conn.Open() 'open the connection Dim emails as new ArrayList() 'to strore emails reader = Cmd.ExecuteReader() 'let the data reader get the emails Do While reader.Read() 'Keep reading until you run out of records emails.add(reader.GetString(numberofyouremailcolumn)) Loop reader.Close() Conn.Close() To send a message: Dim msg as new Web.Mail.MailMessage() msg.To = "someones email" 'and another settings for the msg object... Dim smtpserver as Web.Mail.SMTPMail smtpserver.Send(msg) I hope this clears some things :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.