邮件列表 [英] mailing list

查看:63
本文介绍了邮件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,请帮助我提供示例代码,我可以使用该示例代码在我的网站中创建一个邮件列表,并通过电子邮件将其发送给该邮件列表中的所有成员.

谢谢

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

推荐答案

katumbamartin,

您不需要作为完整应用程序的示例代码,也不太可能从此站点获得它.

以下是您需要实现的概念:
1)一种Web表单,用于捕获愿意接收您的新闻通讯的电子邮件地址.
2)永久存储(如数据库)以保存地址.
3)选择退出表单,将其从数据库中删除(或禁用它们).
4)一种让您制作电子邮件,然后将其提交到您的邮件服务的方法.
5)一种邮件服务,它接受您已启动的电子邮件,然后为您保留的用户列表中的每个活动地址创建并发送一条邮件消息.

这些主题内容详尽,每个主题都应该很容易找到主题信息.

在您的项目中祝您好运.如果您对这些任务中的任何一个有特定的疑问或障碍,请随时在此处提出问题!

干杯.
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.


示例:
C#代码:

字符串配方="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(allRec中的字符串接收器)
如果(接收器!=")
{
试试
{
MailAddress receiverMail =新的MailAddress(receiver);
MailSend(senderMail,receiverMail,"hi","test mail");
}
catch(Exception)
{
}
}

私有void MailSend(MailAddress发送方,MailAddress接收方,字符串主题,字符串正文)
{
MailMessage消息= new MailMessage();
message.From =发件人;
message.To.Add(接收者);
message.IsBodyHtml = true;

message.Body = body;
message.Subject =主题;

SmtpClient smtp =新的SmtpClient();
试试
{
smtp.Send(message);
}
catch(Exception)
{

}
}

在Web config =>

< system.net>
< mailSettings>
< smtp>
<网络主机="127.0.0.1" userName ="密码=" port ="25"/>
</smtp>
</mailSettings>
</system.net>
< system.web> ->在system.web
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


这篇关于邮件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆