在C#中...重要吗? [英] in C# ... important ?

查看:74
本文介绍了在C#中...重要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#项目...在那个项目中,它们是一种形式...在那种形式中,我为用户编写代码以编写详细信息,然后他们将在提交时将它们提交给数据库...提交详细信息(按提交后),数据将发送到数据库,我想要代码通过邮件通知我某人已注册....

所以问题是:我应该用那种形式写什么代码,以便该表单自动发送到我的邮件,表明有人在注册....

感谢

I have project by C# ... in that project they are one form ... in that form I write code for user to write them details and then they will submit it to Data Base ... in seam step when they submit the details (after the press submit) the data will send to Data base and I want code to inform my by mail that some one have register ....

so the Question is : what is the code i should write it in that form so the form will send to my mail Automatically that someone was register ....

thanks

推荐答案



代码项目
Hi,

A good example is here in code project


username = From;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(From, Too);
message.Subject = mail_subject;
message.Body = "Your message body";
SmtpClient client = new SmtpClient(smtp.gmail.com, 587);
message.SubjectEncoding = Encoding.UTF8;
message.Priority = System.Net.Mail.MailPriority.Normal;
client.UseDefaultCredentials = false;
NetworkCredential credential = new NetworkCredential(username, password);
client.UseDefaultCredentials = true;
client.Credentials = credential;
try
{
client.EnableSsl = true;
client.Send(message);
}
catch
{
client.EnableSsl = false;
client.Send(message);
}


这篇关于在C#中...重要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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