Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi there, please help me with a sample code i can use to create a mailing list and in my website and emailing to all the the members in the mailing list.

Thanks
Posted
Comments
Smithers-Jones 15-Oct-10 11:25am    
If you have a specific problem, post it here, and people will help you, but do not ask for code. Describe what you have done so far.

katumbamartin,

That's not so much sample code you're asking for as a complete application, and you're not likely to get it from this site.

Here are the concepts you need to implement:
1) A web form to capture email addresses of those willing to receive your newsletter.
2) Persistent storage (like a database) to save the addresses.
3) An opt-out form that removes them (or disables them) from the database.
4) A way for you to craft emails, then submit them to your mailing service.
5) A mailing service that accepts the email you've started, then creates and sends a mail message for each of the active addresses in your persisted list of users.

These topics are well covered and each should be easy to find topical information on.

Good luck in your project. If you have specific questions or roadblocks on any of these tasks, feel free to drop questions here!

Cheers.
 
Share this answer
 
Example:
C# code:

string recipent = "a@a.com,b@b.com;c@c.com";

char[] separetor = { ',', ';' };
string[] allRec = recipent.Split(separetor);

MailAddress senderMail = new MailAddress("admin@admin.com", "Admin");

foreach (string receiver in allRec)
if (receiver != "")
{
try
{
MailAddress receiverMail = new MailAddress(receiver);
MailSend(senderMail, receiverMail, "hi", "test mail");
}
catch (Exception)
{
}
}

private void MailSend(MailAddress sender, MailAddress receiver, string subject, string body)
{
MailMessage message = new MailMessage();
message.From = sender;
message.To.Add(receiver);
message.IsBodyHtml = true;

message.Body = body;
message.Subject = subject;

SmtpClient smtp = new SmtpClient();
try
{
smtp.Send(message);
}
catch (Exception)
{

}
}

In web config=>

<system.net>
<mailSettings>
<smtp>
<network host="127.0.0.1" userName="" password="" port="25"/>
</smtp>
</mailSettings>
</system.net>
<system.web> -> before system.web
 
Share this answer
 
Comments
shakil0304003 15-Oct-10 13:26pm    
string recipent = "a@a.com,b@b.com;c@c.com"; -> this is mailing list, you can store the mailing list in the database :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900