本文整理汇总了C#中System.Net.Mail.MailAddress类的典型用法代码示例。如果您正苦于以下问题:C# MailAddress类的具体用法?C# MailAddress怎么用?C# MailAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MailAddress类属于System.Net.Mail命名空间,在下文中一共展示了MailAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReadJson
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
string displayName = string.Empty;
string address = string.Empty;
while (reader.Read())
{
var tokenType = reader.TokenType;
if (reader.TokenType == JsonToken.PropertyName)
{
var val = (reader.Value as string )?? string.Empty;
if (val == "DisplayName")
{
displayName = reader.ReadAsString();
}
if (val == "Address")
{
address = reader.ReadAsString();
}
}
if (reader.TokenType == JsonToken.EndObject)
{
break;
}
}
var mailAddress = new MailAddress(address, displayName);
return mailAddress;
}
开发者ID:aduggleby,项目名称:dragon,代码行数:29,代码来源:MailAddressSerializerConverter.cs
示例2: sendMessage
private void sendMessage()
{
MailAddress adresa = new MailAddress("[email protected]");
MailMessage zpráva;
if (logFile)
{
string log;
using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Info", "Log", "logStatusBaru.log")))
{
log = reader.ReadToEnd();
}
if (log.Length > 50000)
log.Remove(50000);
zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text + log);
}
else
{
zpráva = new MailMessage("[email protected]", "[email protected]", předmětTextBox.Text, textZprávyTextBox.Text);
}
SmtpClient klient = new SmtpClient();
klient.Host = "smtp.gmail.com";
klient.Port = 465;
klient.EnableSsl = true;
//klient.Send(zpráva);
}
开发者ID:Cendrb,项目名称:UTU,代码行数:25,代码来源:OdeslatNázor.xaml.cs
示例3: SendMail
public static void SendMail(string subject, string body, ICollection<string> recipients)
{
var fromAddress = new MailAddress("[email protected]", "Bearchop");
const string fromPassword = "alexander0426";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
var message = new MailMessage();
message.From = fromAddress;
message.Subject = subject;
message.Body = body;
var toList = string.Join(",", recipients);
message.To.Add(toList);
smtp.Send(message);
}
开发者ID:vegashat,项目名称:Bearchop,代码行数:28,代码来源:Mail.cs
示例4: Enviar
protected void Enviar(object sender, EventArgs e)
{
MailMessage email = new MailMessage();
MailAddress de = new MailAddress(txtEmail.Text);
email.To.Add("[email protected]");
email.To.Add("[email protected]");
email.To.Add("[email protected]");
email.To.Add("[email protected]");
email.To.Add("[email protected]");
email.To.Add("[email protected]");
email.From = de;
email.Priority = MailPriority.Normal;
email.IsBodyHtml = false;
email.Subject = "Sua Jogada: " + txtAssunto.Text;
email.Body = "Endereço IP: " + Request.UserHostAddress + "\n\nNome: " + txtNome.Text + "\nEmail: " + txtEmail.Text + "\nMensagem: " + txtMsg.Text;
SmtpClient enviar = new SmtpClient();
enviar.Host = "smtp.live.com";
enviar.Credentials = new NetworkCredential("[email protected]", "");
enviar.EnableSsl = true;
enviar.Send(email);
email.Dispose();
Limpar();
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "alert('Email enviado com sucesso!');", true);
}
开发者ID:JulianRSena,项目名称:projeto-suajogada,代码行数:30,代码来源:Contato.aspx.cs
示例5: SendAsync
private void SendAsync(string toStr, string fromStr, string subject, string message)
{
try
{
var from = new MailAddress(fromStr);
var to = new MailAddress(toStr);
var em = new MailMessage(from, to) { BodyEncoding = Encoding.UTF8, Subject = subject, Body = message };
em.ReplyToList.Add(from);
var client = new SmtpClient(SmtpServer) { Port = Port, EnableSsl = SslEnabled };
if (UserName != null && Password != null)
{
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(UserName, Password);
}
client.Send(em);
}
catch (Exception e)
{
Log.Error("Could not send email.", e);
//Swallow as this was on an async thread.
}
}
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:26,代码来源:SystemMailProvider.cs
示例6: Send
public void Send(SPWeb web, IEnumerable<string> emailTo, string senderDisplayName, string subject, string body)
{
if (web == null) throw new ArgumentNullException("web");
if (emailTo == null || !emailTo.Any()) throw new ArgumentNullException("emailTo");
var webApplication = web.Site.WebApplication;
var from = new MailAddress(webApplication.OutboundMailSenderAddress, senderDisplayName);
var message = new MailMessage
{
IsBodyHtml = true,
Body = body,
From = from
};
var smtpServer = webApplication.OutboundMailServiceInstance;
var smtp = new SmtpClient(smtpServer.Server.Address);
foreach (var email in emailTo)
{
message.To.Add(email);
}
message.Subject = subject;
smtp.Send(message);
}
开发者ID:sergeykhomyuk,项目名称:HumanResources.EventsCalendar,代码行数:27,代码来源:EmailService.cs
示例7: send_email_alert
public void send_email_alert(string alert_message)
{
var fromAddress = new MailAddress("[email protected]", "Selenium Alert");
var toAddress = new MailAddress("[email protected]", "Max");
const string fromPassword = "098AZQ102030";
const string subject = "Selenium Alert";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = alert_message
})
{
smtp.Send(message);
}
}
开发者ID:maxunger,项目名称:driv_t,代码行数:29,代码来源:EmailAlert.cs
示例8: Contact
public ViewResult Contact(Contact contact)
{
if (ModelState.IsValid)
{
using (var client = new SmtpClient())
{
var adminEmail = ConfigurationManager.AppSettings["AdminEmail"];
var from = new MailAddress(adminEmail, "MatlabBlog Messenger");
var to = new MailAddress(adminEmail, "MatlabBlog Admin");
using (var message = new MailMessage(from, to))
{
message.Body = contact.Body;
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
message.Subject = contact.Subject;
message.SubjectEncoding = Encoding.UTF8;
message.ReplyTo = new MailAddress(contact.Email);
client.Send(message);
}
}
return View("Thanks");
}
return View();
}
开发者ID:szledak,项目名称:MatlabBlog,代码行数:30,代码来源:BlogController.cs
示例9: SendInscripcion
public static bool SendInscripcion(string email, string url, string html)
{
try
{
using (SmtpClient mailClient = new SmtpClient("smtp.office365.com", 587))
{
//Your SmtpClient gets set to the SMTP Settings you found in the "POP, IMAP, and SMTP access" section from Web Outlook
//SmtpClient mailClient = new SmtpClient("smtp.office365.com");
//Your Port gets set to what you found in the "POP, IMAP, and SMTP access" section from Web Outlook
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
//Set EnableSsl to true so you can connect via TLS
//Your network credentials are going to be the Office 365 email address and the password
mailClient.Credentials = new System.Net.NetworkCredential("[email protected]", "Admin2016");
var from = new MailAddress("[email protected]", "Administracion Cent11",System.Text.Encoding.UTF8);
var to = new MailAddress(email);
MailMessage message = new MailMessage(from, to);
message.Subject = "Formulario de Inscripcion";
message.IsBodyHtml = true;
message.Body = html;
mailClient.Send(message);
return true;
}
}
catch (Exception)
{
throw;
}
}
开发者ID:nahue,项目名称:Terciario,代码行数:33,代码来源:Mailer.cs
示例10: SendEmail
public static bool SendEmail(string EmailToAddress, string emailCCAddresses, string messageBody, string mailSubject)
{
SmtpClient client = new SmtpClient();
try
{
MailAddress maFrom = new MailAddress("[email protected]", "website", Encoding.UTF8);
MailAddress maTo = new MailAddress(EmailToAddress, EmailToAddress, Encoding.UTF8);
MailMessage mmsg = new MailMessage(maFrom.Address, maTo.Address);
mmsg.Body = messageBody;
mmsg.BodyEncoding = Encoding.UTF8;
mmsg.IsBodyHtml = true;
mmsg.Subject = mailSubject;
mmsg.SubjectEncoding = Encoding.UTF8;
if (!string.IsNullOrEmpty(emailCCAddresses))
{
mmsg.CC.Add(emailCCAddresses);
}
client.Send(mmsg);
return true;
}
catch (Exception ex)
{
ExceptionHelper.SendExceptionEmail(ex);
return false;
}
return true;
}
开发者ID:NaeemAkbar,项目名称:LangleyPhar,代码行数:34,代码来源:Email.cs
示例11: SendEmail
public virtual void SendEmail(EmailServerSettings settings, string subject, string body, IEnumerable<MailAddress> toAddressList, MailAddress fromAddress, params EmailAttachmentData[] attachments)
{
using (var smtpClient = GetSmtpClient(settings))
{
var message = new MailMessage();
message.From = fromAddress;
message.Body = body;
message.Subject = subject;
message.IsBodyHtml = true;
foreach (var toAddress in toAddressList)
{
message.To.Add(toAddress);
}
if (attachments != null)
{
foreach (var item in attachments)
{
var stream = StreamHelper.CreateMemoryStream(item.AttachmentData);
stream.Position = 0;
var attachment = new Attachment(stream, item.FileName);
message.Attachments.Add(attachment);
}
}
smtpClient.Send(message);
}
}
开发者ID:mmooney,项目名称:MMDB.RazorEmail,代码行数:30,代码来源:EmailSender.cs
示例12: Send
public void Send(EmailContents emailContents)
{
SmtpClient client = new SmtpClient(SMTPServerName);
client.UseDefaultCredentials = true;
MailAddress from = new MailAddress(emailContents.FromEmailAddress, emailContents.FromName);
MailAddress to = new MailAddress(ToAddress);
MailAddress bcc = new MailAddress(emailContents.Bcc);
MailAddress cc = new MailAddress(emailContents.Cc);
MailMessage message = new MailMessage(from, to);
message.Bcc.Add(bcc);
message.CC.Add(cc);
message.Subject = emailContents.Subject;
message.Body = Utilities.FormatText(emailContents.Body, true);
message.IsBodyHtml = true;
try
{
client.Send(message);
IsSent = true;
}
catch (Exception ex)
{
throw ex;
}
}
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:26,代码来源:EmailManager.cs
示例13: Index
public ActionResult Index(string name, string email, string phone, string message)
{
try
{
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add("[email protected]");
//Configure the address we are sending the mail from
MailAddress address = new MailAddress("[email protected]");
msg.From = address;
msg.Subject = "Website Feedback";
string body = "From: " + name + "\n";
body += "Email: " + email + "\n";
body += "phone: " + phone + "\n\n";
body += message + "\n";
msg.Body = body;
SmtpClient client = new SmtpClient();
client.Host = "relay-hosting.secureserver.net";
client.Port = 25;
//Send the msg
client.Send(msg);
ViewBag.msg = "Mail Sent. Thank You For Contacting Us.";
return View();
}
catch(Exception)
{
ViewBag.msg = "Something Is Wrong. Try Again.";
return View();
}
}
开发者ID:shadmanul,项目名称:AlliedLED_Website_.NET,代码行数:33,代码来源:ContactController.cs
示例14: SendMail
/// <summary>
/// Use to send messages via e-mail to specific account.
/// </summary>
/// <param name="acc">Account , to which e-mail will be sended.</param>
/// <param name="text">Sended text</param>
/// <param name="sub">Subject of letter</param>
public static void SendMail(Account acc, string text,string sub)
{
MailAddress fromAddress = new MailAddress("[email protected]", "SolarAnalys");
var toAddress = new MailAddress(acc.Email);
string fromPassword = "C4llMeIsmael";
//AccountSecurityToken token = new AccountSecurityToken(acc);
string subject=sub??"", body= text??"";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
message.IsBodyHtml = true;
smtp.Send(message);
}
}
开发者ID:Chakalaka11,项目名称:SolarMonitoringApp,代码行数:32,代码来源:Mail.cs
示例15: Send_Click
private void Send_Click(object sender, EventArgs e)
{
try
{
Output.Text = string.Empty;
FileInfo file = new FileInfo(_file);
StreamReader rdr = file.OpenText();
string messageBody = rdr.ReadToEnd();
rdr.Dispose();
SmtpClient client = new SmtpClient("some.mail.server.example.com");
client.Credentials = new NetworkCredential("someuser", "somepassword");
MailAddress from = new MailAddress("[email protected]");
MailAddress to = new MailAddress("[email protected]");
MailMessage msg = new MailMessage(from, to);
msg.Body = messageBody;
msg.Subject = "Test message";
//client.Send(msg);
Output.Text = "Sent email with body: " + Environment.NewLine + messageBody;
}
catch (Exception ex)
{
Output.Text = ex.ToString();
}
}
开发者ID:jheintz,项目名称:presentations-and-training,代码行数:26,代码来源:Form1.cs
示例16: ParseRequestInfo
public ApiRequest ParseRequestInfo(string address)
{
try
{
var mailAddress = new MailAddress(address);
var match = RouteRegex.Match(mailAddress.User);
if (!match.Success)
return null;
var tenant = CoreContext.TenantManager.GetTenant(mailAddress.Host);
if (tenant == null)
return null;
var groups = RouteRegex.GetGroupNames().ToDictionary(groupName => groupName, groupName => match.Groups[groupName].Value);
var requestInfo = ParseRequestInfo(groups, tenant);
requestInfo.Method = "POST";
requestInfo.Tenant = tenant;
if (!string.IsNullOrEmpty(requestInfo.Url))
requestInfo.Url = string.Format("api/2.0/{0}.json", requestInfo.Url);
return requestInfo;
}
catch
{
return null;
}
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:32,代码来源:AddressParser.cs
示例17: SendForgotPasswordMail
public static void SendForgotPasswordMail(string email, string callbackUrl)
{
try
{
using (SmtpClient mailClient = new SmtpClient("smtp.office365.com", 587))
{
//Your SmtpClient gets set to the SMTP Settings you found in the "POP, IMAP, and SMTP access" section from Web Outlook
//Your Port gets set to what you found in the "POP, IMAP, and SMTP access" section from Web Outlook
mailClient.Port = 587;
//Set EnableSsl to true so you can connect via TLS
mailClient.EnableSsl = true;
//Your network credentials are going to be the Office 365 email address and the password
mailClient.Credentials = new System.Net.NetworkCredential("[email protected]", "Admin2016");
var from = new MailAddress("[email protected]", "Administracion Cent11", System.Text.Encoding.UTF8);
var to = new MailAddress(email);
MailMessage message = new MailMessage(from, to);
message.Subject = "Restablecer contraseña";
message.IsBodyHtml = true;
message.Body = "Para restablecer la contraseña, haga clic <a href=\"" + callbackUrl + "\">aquí</a>";
mailClient.Send(message);
}
}
catch (Exception)
{
throw;
}
}
开发者ID:nahue,项目名称:Terciario,代码行数:30,代码来源:Mailer.cs
示例18: sendMail
public static void sendMail(String host, String user, String pwd, String fromMail, String toMail, String subject, String strbody)
{
// Command line argument must the the SMTP host.
SmtpClient client = new SmtpClient(host, 25);
client.Credentials = new System.Net.NetworkCredential(user, pwd);
// Specify the e-mail sender.
// Create a mailing address that includes a UTF8 character
// in the display name.
MailAddress from = new MailAddress(fromMail, "Tradestation",
System.Text.Encoding.UTF8);
// Set destinations for the e-mail message.
MailAddress to = new MailAddress(toMail);
// Specify the message content.
MailMessage message = new MailMessage(from, to);
message.Body = strbody;
// Include some non-ASCII characters in body and subject.
string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192', '\u2193' });
message.Body += Environment.NewLine + someArrows;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = subject + someArrows;
message.SubjectEncoding = System.Text.Encoding.UTF8;
// Set the method that is called back when the send operation ends.
client.SendCompleted += new
SendCompletedEventHandler(SendCompletedCallback);
// The userState can be any object that allows your callback
// method to identify this send operation.
// For this example, the userToken is a string constant.
string userState = "test message1";
client.Send(message);
// Clean up.
message.Dispose();
Console.WriteLine("Goodbye.");
}
开发者ID:jiangzhonghui,项目名称:tradestation,代码行数:33,代码来源:Service1.cs
示例19: Start
public async Task<Autodiscover> Start(string domainOrUsername)
{
var domain = domainOrUsername;
try
{
domain = new MailAddress(domainOrUsername).Host;
}
catch (FormatException)
{
}
var response = await DiscoverSection(true, domain);
if (response == null || (response != null && response.Data == null))
{
response = await DiscoverSection(false, domain);
}
if (response != null && response.Data != null)
{
return await FollowRedirects(response.Data.FromBytes<Autodiscover>());
}
else
{
throw new DiscoveryException(string.Format("Discovery was unable to find resource for domain: {0}", domain));
}
}
开发者ID:ShelbyZ,项目名称:UCWA.NET,代码行数:27,代码来源:Discovery.cs
示例20: RequestNotification
public bool RequestNotification(string notificationUid, string address, string value)
{
_Trace.TraceEvent(TraceEventType.Verbose, (int)Events.SendRequest, string.Format("RequestNotification( {0}, {1}, {2} )", notificationUid, address, value));
MailAddress to = new MailAddress(address);
MailMessage message = new MailMessage(_Emailer.From, to);
message.Subject = _Subject;
message.Body = value;
try
{
_Emailer.Client.Send(message);
}
catch (System.Net.Mail.SmtpFailedRecipientException ex)
{
_Trace.TraceEvent(TraceEventType.Error, (int)Events.SendError, string.Format("{0}\r\n{1}", notificationUid, ex.ToString()));
return false;
}
catch (System.Net.Mail.SmtpException ex)
{
_Trace.TraceEvent(TraceEventType.Error, (int)Events.SendError, string.Format("{0}\r\n{1}", notificationUid, ex.ToString()));
return false;
}
_Trace.TraceEvent(TraceEventType.Verbose, (int)Events.SendSuccess, notificationUid);
return true;
}
开发者ID:mrgcohen,项目名称:CriticalResultsTransporter,代码行数:25,代码来源:SmtpTransportService.cs
注:本文中的System.Net.Mail.MailAddress类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论