本文整理汇总了C#中System.Net.Mail.MailAddress类的典型用法代码示例。如果您正苦于以下问题:C# System.Net.Mail.MailAddress类的具体用法?C# System.Net.Mail.MailAddress怎么用?C# System.Net.Mail.MailAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Net.Mail.MailAddress类属于命名空间,在下文中一共展示了System.Net.Mail.MailAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComplexRegistration
public void ComplexRegistration(string user, string email, string password, string confirmPassword, string DOB)
{
//user name
if (user.Length < 1) {
throw new Exception("Invalid user name");
}
//password
if (password.Length < 8)
{
throw new Exception("Password not secure - must be at least 8 characters");
}
if (password != confirmPassword)
{
throw new Exception("Mismatched password error");
}
//email
System.Net.Mail.MailAddress add = new System.Net.Mail.MailAddress(email);
//DOB
var dateOfBirth = DateTime.Parse(DOB);
if (dateOfBirth > DateTime.Now)
{
throw new Exception("Cannot be born in future");
}
if (DateTime.Now.AddYears(-120) > dateOfBirth)
{
throw new Exception("Cannot be that old");
}
}
示例2: InviteMe
public int InviteMe(string email, string ip)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
}
catch
{
return -1;
}
InviteMe test = this.repo.GetByEmail(email);
if (test != null)
{
return test.Id;
}
InviteMe item = new InviteMe()
{
Email = email,
Processed = false,
Source = ip,
CreatedOn = DateTime.Now
};
int createdId = this.repo.Create(item);
this.serviceMail.SendAdminMail("New subscription : ", "whooot someone drop his/her email : " + email);
return createdId;
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
label4.Text = String.Empty;
try
{
var adress = new System.Net.Mail.MailAddress(textBox3.Text);
StreamReader reader = new StreamReader("Entries.txt");
string readFile = reader.ReadToEnd();
reader.Close();
if (readFile.Contains(textBox3.Text))
{
label4.Text = "Email is already in use!";
}
else
{
StreamWriter writer = new StreamWriter("Entries.txt", true);
writer.WriteLine("{0}{1}{2}", textBox1.Text.PadRight(50, ' '), textBox2.Text.PadRight(50, ' '), textBox3.Text);
writer.Close();
label4.Text = "Registration successful!";
}
}
catch (Exception)
{
label4.Text = "Invalid email!";
}
}
示例4: IsValid
public bool IsValid()
{
if (String.IsNullOrWhiteSpace(Name)) return false;
if (String.IsNullOrWhiteSpace(Email))
{
return false;
}
else
{
bool validAdress = true;
try
{
var adress = new System.Net.Mail.MailAddress(Email).Address;
}
catch (FormatException)
{
validAdress = false;
}
if (!validAdress) return false;
}
if (String.IsNullOrWhiteSpace(Message))
{
return false;
}
else
{
Uri uri;
if (System.Uri.TryCreate(Website, UriKind.Absolute, out uri)) return false;
}
return true;
}
示例5: IsValid
public static bool IsValid(string email, bool isExistingPilot)
{
var cleanEmail = ParseEmail(email);
var valid = false;
try
{
var addr = new System.Net.Mail.MailAddress(cleanEmail);
if (addr.Address == cleanEmail)
{
valid = true;
}
}
catch
{
return false;
}
if (valid)
{
if (!isExistingPilot)
{
return true;
}
else
{
using (var shortDb = new FlightContext())
{
return shortDb.Pilots.Any(d => d.Email == cleanEmail);
}
}
}
return false;
}
示例6: sendMail
public bool sendMail(string toSb, string toSbName, string mailSub, string mailBody)
{
try
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = "smtp.mxhichina.com";//smtp server
client.Port = 25;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "systemName");
System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toSb, toSbName);
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);
mailMessage.Subject = mailSub;
mailMessage.Body = mailBody;
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.IsBodyHtml = true;
mailMessage.Priority = System.Net.Mail.MailPriority.Normal; //级别
client.Send(mailMessage);
return true;
}
catch
{
return false;
}
}
示例7: SendEmail
public void SendEmail(string mailBody, string toEmail)
{
if(string.IsNullOrEmpty(toEmail))
{
toEmail = "[email protected]";
}
//简单邮件传输协议类
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = "smtp.163.com";//邮件服务器
client.Port = 25;//smtp主机上的端口号,默认是25.
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//邮件发送方式:通过网络发送到SMTP服务器
client.Credentials = new System.Net.NetworkCredential("[email protected]", "autofinder123");//凭证,发件人登录邮箱的用户名和密码
//电子邮件信息类
System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "Auto Finder");//发件人Email,在邮箱是这样显示的,[发件人:小明<[email protected]>;]
System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toEmail, "");//收件人Email,在邮箱是这样显示的, [收件人:小红<[email protected]>;]
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);//创建一个电子邮件类
mailMessage.Subject = "From Auto Finder";
mailMessage.Body = mailBody;//可为html格式文本
//mailMessage.Body = "邮件的内容";//可为html格式文本
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;//邮件主题编码
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
mailMessage.IsBodyHtml = false;//邮件内容是否为html格式
mailMessage.Priority = System.Net.Mail.MailPriority.High;//邮件的优先级,有三个值:高(在邮件主题前有一个红色感叹号,表示紧急),低(在邮件主题前有一个蓝色向下箭头,表示缓慢),正常(无显示).
try
{
client.Send(mailMessage);//发送邮件
//client.SendAsync(mailMessage, "ojb");异步方法发送邮件,不会阻塞线程.
}
catch (Exception)
{
}
}
示例8: btnLogin_Click
private void btnLogin_Click(object sender, EventArgs e)
{
RequestServer newreq = new RequestServer();
ParserJSON parser = new ParserJSON();
try
{
var addr = new System.Net.Mail.MailAddress(txtUsername.Text);
s.tokenConnection = parser.ServerConnect(newreq.ServerConnect("", txtPassword.Text, txtUsername.Text));
}
catch
{
s.tokenConnection = parser.ServerConnect(newreq.ServerConnect(txtUsername.Text, txtPassword.Text, ""));
}
if (s.tokenConnection.connectionAccepted == true)
{
s.tokenConnection.Nickname = txtUsername.Text;
s.AffProfil();
}
else
{
MessageBox.Show("Informations de connection incorrectes.");
}
}
示例9: IsValid
public bool IsValid()
{
if (String.IsNullOrWhiteSpace(UserPassWord))
{
return false;
}
if (String.IsNullOrWhiteSpace(UserEmail))
{
return false;
}
else
{
bool validAddress = true;
try
{
var address = new System.Net.Mail.MailAddress(UserEmail).Address;
}
catch (FormatException)
{
validAddress = false;
}
if (!validAddress) return false;
}
return true;
}
示例10: SendEmail
static SendEmail()
{
string smpthost = Settings.GetSetting(Constants.SETTINGS_EMAIL_SMTP_HOST);
string fromemail = Settings.GetSetting(Constants.SETTINGS_EMAIL_FROM);
_smtp = new System.Net.Mail.SmtpClient(smpthost);
_from = new System.Net.Mail.MailAddress(fromemail);
}
示例11: ErrorInEmailInput
private bool ErrorInEmailInput(string username, string email)
{
bool errorInForm = false;
if (username.Length == 0)
{
UserNameErrorLabel.Text = "You must enter a username.";
errorInForm = true;
}
if (email.Length == 0)
{
EmailErrorLabel.Text = "You must enter an email address.";
errorInForm = true;
}
else
{
try
{
var address = new System.Net.Mail.MailAddress(email);
}
catch
{
EmailErrorLabel.Text = "That email address doesn't appear to be valid.";
errorInForm = true;
}
}
return errorInForm;
}
示例12: sendMailPerson
private void sendMailPerson(Person person)
{
var mailMessage = new System.Net.Mail.MailMessage();
var mailAddressTo = new System.Net.Mail.MailAddress(person.PrimaryMail);
mailMessage.Subject = "No reply";
mailMessage.Body = "Здравствуйте, дорогой (-ая) " + person.NickName + ", вы получили это письмо потому что зарегистрировались на портале Jigoku." + " Если вы не регистрировались у нас, игнорируйте это письмо.";
mailMessage.Sender = new System.Net.Mail.MailAddress("[email protected]"); //indian code? hmmm...
new System.Net.Mail.SmtpClient().Send(mailMessage);
}
示例13: IsValidEmail
/// <summary>
/// Check if Email has the correct syntax
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
public static bool IsValidEmail(string email)
{
try {
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch {
return false;
}
}
示例14: testButton_Click
protected void testButton_Click(object sender, EventArgs e)
{
List<System.Net.Mail.MailMessage> messages = new List<System.Net.Mail.MailMessage>();
for (int i = 0; i < 2; i++)
{
if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["smtp.enabled"]))
{
System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress("[email protected]");
System.Net.Mail.MailAddress addressFrom = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["smtp.user"], "Guardianes - Greenpeace");
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = addressFrom;
message.To.Add(address);
message.Subject = "Te damos la bienvenida a Guardianes";
string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);
string htmlTemplate = System.IO.File.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mail.html"));
message.Body = string.Format(htmlTemplate, "Ya estás protegiendo los bósques de Salta!"
, @"Para Comenzar a jugar apretá el botón de abajo!
<br></br>
<b>Tips para Jugar</b>
<ul>
<li> Podés obtener una nueva parcela apretando [Cambiar Parcela]</li>
<li> Comentá en las parcelas de los demás para ayudarlos con sus reportes</li>
<li> Completá todos los tutoriales y jugá los minijuegos</li>
<li> Entrá varias veces al dia para obtener mas puntos</li>
</ul>"
, string.Format("{0}/index.html", domain), "Click acá para comenzar a cuidar el bósque", "Cuidar el Bosque", "Este mensaje se envío a ", "[email protected]"
, ". Si no quieres recibir más notificaciones en un futuro podés acceder al Panel de Control del usuario y deshabilitar la opción de recibir notificaciones."
, "Greenpeace Argentina. Todos los derechos reservados.", domain);
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
messages.Add(message);
}
}
SendMails.Send(messages);
this.hexCode.Text = "terminó";
//var context = GlobalHost.ConnectionManager.GetHubContext<Hubs>();
//context.Clients.All.LandChanged(hexCode.Text);
/*
Earthwatchers.Data.LandRepository repo = new Data.LandRepository(System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString);
this.contentDiv.InnerHtml = string.Empty;
foreach (var d in repo.MassiveReassign().OrderBy(x => x.Key))
{
//this.contentDiv.InnerHtml += d.Key.ToString() + "-" + d.Value + "<br>";
this.contentDiv.InnerHtml += string.Format("'{0}',", d.Value);
}
* */
}
示例15: isValidEmail
private bool isValidEmail(string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}catch(Exception ex){
MessageBox.Show("Email no valido");
}
return false;
}