Heey
Im making a Newletter form,
and im having a little problem making it.
i have 3 news-groups, that i can choose from a DropDownList
and when i choose a news-group and press send i should send a mail to the people that has subscribed to that newsletter,
plz help
Loading
Sam HobbsPosted Nov 9, 2011, 10:16 PM
There are articles in this web site to help with each one of those.
Javeed M ShaikhPosted Nov 9, 2011, 7:54 AM
follow these steps:
1. taking the selected value of the newsgroup from the dropdownlist you should call the database and get all the registered members email address for that group.
2. if you want to send individual emails than you have to loop through the records and send email to individual address, otherwise if you want to send them all together than you need to combine all the email addresses in a string and send the email (I think there is a limit to the number of people you are sending email).
3. Following is the code to send email:
try
{
// Creating a new SMTP Client.
SmtpClient client = new SmtpClient("SMTP Server IP");
// Creating a new mail message.
MailMessage message = new MailMessage("FromEmailAddress", "ToEmailAddresses");
// The message body
message.Body = "Message Body";
// The message subject
message.Subject = "Message Subject";
// Some servers require a specific port to connect,
client.Port = "PortNumber";
// Send the message.
client.Send(message);
}
// This catches the exceptions, if any.
catch (Exception ex)
{
// Show a message, explaining the problem.
MessageBox.Show("Cannot send message: " + ex.Message);
}