Email form to database list of users

chefytim

New member
Joined
Jun 3, 2003
Messages
2
Location
Cookeville, TN
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
 
Look into this class:
System.Web.Mail.SmtpMail
Its small and pretty selfexplanatory :) But you will need an SMTP service running on your server.
 
From IIS Admin you can configure your SMTP Servre. and then with this class

System.Web.Mail.SMTP

you can send emails.
 
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
 
First you have to connect to the database...
Code:
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:
Code:
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 :)
 
Back
Top