本文整理汇总了C#中System.Net.Mail.SmtpClient类的典型用法代码示例。如果您正苦于以下问题:C# System.Net.Mail.SmtpClient类的具体用法?C# System.Net.Mail.SmtpClient怎么用?C# System.Net.Mail.SmtpClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Net.Mail.SmtpClient类属于命名空间,在下文中一共展示了System.Net.Mail.SmtpClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendSenha
public static bool SendSenha(string from, string to, string subject, string mensagem)
{
System.Net.Mail.SmtpClient s = null;
try
{
s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
s.EnableSsl = true;
s.UseDefaultCredentials = false;
s.Credentials = new System.Net.NetworkCredential("[email protected]", "Projeto032015");
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
new System.Net.Mail.MailAddress(from),
new System.Net.Mail.MailAddress(to));
message.Body = mensagem;
message.BodyEncoding = Encoding.UTF8;
message.Subject = subject;
message.SubjectEncoding = Encoding.UTF8;
s.Send(message);
s.Dispose();
return true;
}
catch
{
return false;
}
finally
{
if (s != null)
s.Dispose();
}
}
开发者ID:tematek,项目名称:ProjetoMelhor,代码行数:31,代码来源:DisparaSenha.cs
示例2: Enviar
public void Enviar(string y, string tipo, string texto)
{
System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
correo.From = new System.Net.Mail.MailAddress("[email protected]");
correo.To.Add(y);
string sub = "Tutorias compu informa";
string tex = "Este mensaje es para informar que se tendran que " + tipo + "\n" + texto;
correo.Subject = sub;
correo.Body = tex;
correo.IsBodyHtml = false;
correo.Priority = System.Net.Mail.MailPriority.Normal;
//
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
//
//---------------------------------------------
// Estos datos debes rellanarlos correctamente
//---------------------------------------------
smtp.Host = "smtp-mail.outlook.com";
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "EscuelaComputacion12");
smtp.EnableSsl = false;
smtp.Port = 587;
smtp.EnableSsl = true;
try
{
smtp.Send(correo);
}
catch (Exception ex)
{
var a = ex;
}
}
开发者ID:Eur,项目名称:Proyecto,代码行数:31,代码来源:MovilController.cs
示例3: Send
public static void Send(string destination, string subject, string body)
{
var credentialUserName = "[email protected]";
var sentFrom = "[email protected]";
var pwd = "quiko";
// Configure the client:
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.riquest.de");
client.Port = 25;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
// Create the credentials:
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(credentialUserName, pwd);
client.EnableSsl = false;
client.Credentials = credentials;
// Create the message:
var mail = new System.Net.Mail.MailMessage(sentFrom, destination);
mail.Subject = subject;
mail.Body = body;
// Send:
client.Send(mail);
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:27,代码来源:EmailClient.cs
示例4: CoverDetails
public ActionResult CoverDetails(Models.CoverDetailsModel submittedCoverDetails)
{
//Check if the current session has completed pre-req
if (this.Session[cPersonalDetails] == null)
return RedirectToAction("PersonalDetails");
//Check if a Submission has already been done
if (SessionIsComplete())
return View("SubmissionCompleted");
//Check if current Post details are valid.
if (submittedCoverDetails != null && this.ModelState.IsValid)
{
var personalDetails = Session[cPersonalDetails] as Models.PersonalDetailsModel;
var mail = CreateMail(personalDetails, submittedCoverDetails);
using (var mc = new System.Net.Mail.SmtpClient())
{
mc.Send(mail);
}
CompleteSession();
return View("SubmissionCompleted");
}
return View(submittedCoverDetails);
}
开发者ID:carcer,项目名称:contact,代码行数:25,代码来源:HomeController.cs
示例5: emailEvent
} // End Sub handleLog
private void emailEvent() // Send email notification
{
try
{
System.Net.Mail.MailMessage notificationEmail = new System.Net.Mail.MailMessage();
notificationEmail.Subject = "SysLog Event";
notificationEmail.IsBodyHtml = true;
notificationEmail.Body = "<b>SysLog Event Triggered:<br/><br/>Time: </b><br/>" +
System.DateTime.Now.ToString() + "<br/><b>Source IP: </b><br/>" +
source + "<br/><b>Event: </b><br/>" + log; // Throw in some basic HTML for readability
notificationEmail.From = new System.Net.Mail.MailAddress("[email protected]", "SysLog Server"); // From Address
notificationEmail.To.Add(new System.Net.Mail.MailAddress("[email protected]", "metastruct")); // To Address
System.Net.Mail.SmtpClient emailClient = new System.Net.Mail.SmtpClient("10.10.10.10"); // Address of your SMTP server of choice
// emailClient.UseDefaultCredentials = false; // If your SMTP server requires credentials to send email
// emailClient.Credentials = new NetworkCredential("username", "password"); // Supply User Name and Password
emailClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
emailClient.Send(notificationEmail); // Send the email
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.ToString());
}
} // End Sub emailEvent
开发者ID:ststeiger,项目名称:SyslogClients,代码行数:31,代码来源:loghandler.cs
示例6: SendNoticeToAdmin
public static void SendNoticeToAdmin(string subject, string content, MimeType mime) {
UserBE adminUser = UserBL.GetAdmin(); ;
if (adminUser == null) {
throw new DreamAbortException(DreamMessage.InternalError(DekiResources.CANNOT_RETRIEVE_ADMIN_ACCOUNT));
}
string smtphost = string.Empty;
int smtpport = 0;
if (smtphost == string.Empty)
throw new DreamAbortException(DreamMessage.Conflict(DekiResources.SMTP_SERVER_NOT_CONFIGURED));
if (string.IsNullOrEmpty(adminUser.Email))
throw new DreamAbortException(DreamMessage.Conflict(DekiResources.ADMIN_EMAIL_NOT_SET));
System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(adminUser.Email);
msg.From = new System.Net.Mail.MailAddress(DekiContext.Current.User.Email, DekiContext.Current.User.Name);
msg.Subject = DekiContext.Current.Instance.SiteName + ": " + subject;
msg.Body = content;
smtpclient.Host = smtphost;
if (smtpport != 0)
smtpclient.Port = smtpport;
smtpclient.Send(msg);
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:SiteBL.cs
示例7: SMTPMail
//*****//
//EMAIL//
//*****//
public void SMTPMail(string pDestino, string pAsunto, string pCuerpo)
{
// Crear el Mail
using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
{
mail.To.Add(new System.Net.Mail.MailAddress(pDestino));
mail.From = new System.Net.Mail.MailAddress("[email protected]");
mail.Subject = pAsunto;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = pCuerpo;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = false;
// Agregar el Adjunto si deseamos hacerlo
//mail.Attachments.Add(new Attachment(archivo));
// Configuración SMTP
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
// Crear Credencial de Autenticacion
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "ReNb3270");
smtp.EnableSsl = true;
try
{ smtp.Send(mail); }
catch (Exception ex)
{ throw ex; }
} // end using mail
}
开发者ID:richy-maximo,项目名称:Checador,代码行数:32,代码来源:Util.cs
示例8: enviarCorreoElectronico
public static bool enviarCorreoElectronico(string pcorreoDestino, string tecnologia, string pnombreCandidato,DateTime pfechaI,DateTime pfechaF, string phora, string pcontrasenna)
{
System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
correo.From = new System.Net.Mail.MailAddress("[email protected]");
correo.To.Add(pcorreoDestino);
correo.Subject = "Prueba"+" de "+tecnologia ;
correo.Body = "<html><body>[email protected] " + pnombreCandidato + ", <br> Este correo es con la intención de comunicarle que la programación de la prueba de " + tecnologia + " ya puede ser accesada.<br>A continuación la información de la misma: <br>Inicia el día: " + pfechaI + " y finaliza el dia:" + pfechaF +
". <br>La prueba tiene que ser completada en un máximo de " + phora + " horas." +
"<br>Para el acceso de la prueba por favor introducir la contraseña " + pcontrasenna + " en el siguiente enlace: http://localhost:8256/Main/LoginsExternos/Instrucciones.aspx </body></html>";
correo.IsBodyHtml = true;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "diegoChing");
smtp.EnableSsl = true;
try
{
smtp.Send(correo);
return true;
}
catch (Exception ex)
{
return false;
throw new Exception ("Ha ocurrido un error al enviar el correo electronico ", ex);
}
}
开发者ID:pablobar23,项目名称:RRHH,代码行数:31,代码来源:CorreoElectronico.cs
示例9: send_mail_gmail
public static bool send_mail_gmail(string gmail_sender_account, string gmail_sender_pass, string sender_name, string sender_email, string receiver_name, string receiver_email, string subject, string body_content)
{
bool flag = false;
System.Net.NetworkCredential smtp_user_info = new System.Net.NetworkCredential(gmail_sender_account, gmail_sender_pass);
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
mailMessage.From = new System.Net.Mail.MailAddress(sender_email, sender_name, System.Text.UTF8Encoding.UTF8);
mailMessage.To.Add(new System.Net.Mail.MailAddress(receiver_email, receiver_name.Trim(), System.Text.UTF8Encoding.UTF8));
mailMessage.Subject = subject;
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mailMessage.Body = body_content;
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = System.Text.UnicodeEncoding.UTF8;
//mailMessage.Priority = MailPriority.High;
/* Set the SMTP server and send the email - SMTP gmail ="smtp.gmail.com" port=587*/
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587; //port=25
smtp.Timeout = 100;
smtp.EnableSsl = true;
smtp.Credentials = smtp_user_info;
try
{
smtp.Send(mailMessage);
flag = true;
}
catch (Exception ex)
{
ex.ToString();
}
return flag;
}
开发者ID:jackiechou,项目名称:thegioicuaban.com,代码行数:34,代码来源:EmailClass.cs
示例10: NotificarRecuperacionContrasenia
//private string mailFrom = "[email protected]";//ConfigurationSettings.AppSettings["MailAdmin"];
//private string smtp = "smtp.educaria.com";//ConfigurationSettings.AppSettings["Smtp"];
//private string smtpUserName = "[email protected]";//ConfigurationSettings.AppSettings["SmtpUserName"];
//private string smtpPassword = "senda.portalchile";//ConfigurationSettings.AppSettings["SmtpPwd"];
public void NotificarRecuperacionContrasenia(Usuario Usr, string Password)
{
try
{
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.From = new System.Net.Mail.MailAddress(mailFrom);
mm.To.Add(Usr.Email);
mm.Subject = "CAMBIO DE CONTRASEÑA DE SENDA PORTAL";
mm.Body = Usr.Nombres+" "+Usr.ApellidoMaterno+" "+Usr.ApellidoPaterno + ",\r La contraseña de acceso a Senda Portal se generó con éxito. \r\rUsuario: " + Usr.Rut + " \r Contraseña: " + Password;
mm.IsBodyHtml = true;
mm.BodyEncoding = System.Text.Encoding.Default;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);
smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName,smtpPassword);
smtpClient.EnableSsl = false;
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Send(mm);
}
catch(Exception ex)
{
throw new Exception(ex.InnerException.Message,ex);
}
}
开发者ID:enzoburga,项目名称:pimesoft,代码行数:32,代码来源:NotificacionEmail.cs
示例11: NotificarCambioEMail
internal void NotificarCambioEMail(SendaPortal.BussinesRules.ConfirmacionEMail confirmacion)
{
try
{
string dominioPrincipal = System.Configuration.ConfigurationManager.AppSettings["DominioPrincipal"];
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.From = new System.Net.Mail.MailAddress(mailFrom);
mm.To.Add(confirmacion.Email);
mm.Subject = "CONFIRMACIÓN DE CAMBIO DE EMAIL DE SENDA PORTAL";
mm.Body = @"<html><body><span style=""font-size: 10pt; font-family: Verdana"">" + confirmacion.Usuario.Nombres + "<br /><br /> Usted ha solicitado el cambio de su dirección de correo electrónico de Senda Portal. Para confirmar el cambio debe hacer click en el siguiente link:<br /><br /></span><a href=\"http://" + dominioPrincipal + "/MiSendaPortal/ConfirmacionCambioEMail.aspx?Hash=" + confirmacion.Hash + " \"><span style=\"font-size: 10pt; font-family: Verdana\">Confirmar cambio de E-Mail</span></a><span style=\"font-size: 10pt; font-family: Verdana\"></span></body></html>";
mm.IsBodyHtml = true;
mm.BodyEncoding = System.Text.Encoding.Default;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);
smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);
smtpClient.EnableSsl = false;
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Send(mm);
}
catch (Exception ex)
{
throw new Exception(ex.InnerException.Message, ex);
}
}
开发者ID:enzoburga,项目名称:pimesoft,代码行数:28,代码来源:NotificacionEmail.cs
示例12: ConfirmMail
public ActionResult ConfirmMail([Bind(Exclude = "AuthCode")] string uid, UserInfo userinfo)
{
try
{
using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope())
{
userinfo = db.UserInfo.FirstOrDefault(p => p.Uid == uid);
userinfo.Email = Request["newmail"];
userinfo.AuthCode = Guid.NewGuid().ToString();
UpdateModel(userinfo);
db.SubmitChanges();
System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("smtp.qq.com", 25);
sc.Credentials = new System.Net.NetworkCredential("342354548", "0oO0oO");
sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
string verify_url = new Uri(Request.Url, System.Web.Routing.RouteTable.Routes.GetVirtualPath
(Request.RequestContext, new System.Web.Routing.RouteValueDictionary
(new { action = "Verify", authCode = userinfo.AuthCode })).VirtualPath).AbsoluteUri;
sc.Send("[email protected]", userinfo.Email, "会员注册确认信", verify_url);
transaction.Complete();
}
Session["CurrentUser"] = null;
return Content("验证邮件已发出,请验证后重新登录!");
}
catch (Exception ex)
{
ex.ToString();
return Content("验证邮箱不存在,请重新填写!");
}
}
开发者ID:zl2928511,项目名称:OnlineMusic,代码行数:29,代码来源:MemberController.cs
示例13: Send
/// <summary>
/// 네이버 계정으로 메일을 발송합니다.
/// </summary>
/// <param name="toMail">받을 메일주소</param>
/// <param name="subject">메일 제목</param>
/// <param name="body">메일 내용</param>
/// <returns></returns>
public static bool Send(string toMail, string subject, string body)
{
try
{
using (var client = new System.Net.Mail.SmtpClient(SmtpMailAddress))
{
client.Credentials = new System.Net.NetworkCredential(GoogleAccountID, GoogleAccountPwd);
client.EnableSsl = true;
client.Port = 587;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.Subject = subject;
message.From = new System.Net.Mail.MailAddress(FromMail);
message.To.Add(toMail);
message.IsBodyHtml = true;
message.Body = body;
client.Send(message);
return true;
}
}
catch
{
return false;
}
}
开发者ID:parkheesung,项目名称:SharedPlayer,代码行数:32,代码来源:Mail.cs
示例14: 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;
}
}
开发者ID:chuliam,项目名称:sziit_Research,代码行数:26,代码来源:Mail.cs
示例15: ConfigHotmailAccount
private async Task ConfigHotmailAccount(IdentityMessage message)
{
// Credentials:
var credentialUserName = ConfigurationManager.AppSettings["emailService:Account"];
var sentFrom = credentialUserName;
var pwd = ConfigurationManager.AppSettings["emailService:Password"];
// Configure the client:
System.Net.Mail.SmtpClient client =
new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
// Create the credentials:
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(credentialUserName, pwd);
client.EnableSsl = true;
client.Credentials = credentials;
// Create the message:
var mail =
new System.Net.Mail.MailMessage(sentFrom, message.Destination);
mail.Subject = message.Subject;
mail.Body = message.Body;
// Send:
await client.SendMailAsync(mail);
}
开发者ID:evangistudio,项目名称:OA2B.AuthCabinet,代码行数:32,代码来源:EmailService.cs
示例16: ButtonClearLock_Click
private void ButtonClearLock_Click(object sender, RoutedEventArgs e)
{
if(this.ListViewLockedAccessionOrders.SelectedItem != null)
{
MessageBoxResult result = MessageBox.Show("Clearing a lock may cause data loss. Are you sure you want to unlock this case?", "Possible data loss", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
{
foreach(YellowstonePathology.Business.Test.AccessionLock accessionLock in this.ListViewLockedAccessionOrders.SelectedItems)
{
YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(accessionLock.MasterAccessionNo, this);
accessionOrder.AccessionLock.ReleaseLock();
YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this);
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("[email protected]", "[email protected]", System.Windows.Forms.SystemInformation.UserName, "A lock wash cleared on case: " + accessionOrder.MasterAccessionNo + " by " + YellowstonePathology.Business.User.SystemIdentity.Instance.User.DisplayName);
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");
Uri uri = new Uri("http://tempuri.org/");
System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials;
System.Net.NetworkCredential credential = credentials.GetCredential(uri, "Basic");
client.Credentials = credential;
client.Send(message);
}
this.m_AccessionLockCollection.Refresh();
this.NotifyPropertyChanged(string.Empty);
}
}
}
开发者ID:ericramses,项目名称:YPILIS,代码行数:27,代码来源:LockedCaseDialog.xaml.cs
示例17: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
textBox1.Text = Environment.Version.ToString(3);
System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient();
sc.Send("pet", "a", "c", "d");
}
开发者ID:raba930,项目名称:01-NetFramework,代码行数:7,代码来源:Form1.cs
示例18: buttonSend_Click
private void buttonSend_Click(object sender, EventArgs e)
{
if (textBoxTitle.Text != "" || textBoxContent.Text != "")
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = "smtp.163.com";
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("hscscard", "11111111");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("[email protected]", "[email protected]");
message.Subject = textBoxTitle.Text;
message.Body = textBoxContent.Text;
String version = FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion;
message.Body += String.Format("[版本号:{0}]", version);
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
}
catch (Exception ex)
{
MessageBox.Show(@"Send Email Failed." + ex);
}
}
Close();
}
开发者ID:narlon,项目名称:TOMClassic,代码行数:28,代码来源:ConnectForm.cs
示例19: 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)
{
}
}
开发者ID:kaysonli,项目名称:zoneky,代码行数:34,代码来源:EmailHelper.cs
示例20: Send
public void Send(YellowstonePathology.YpiConnect.Contract.Message message)
{
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(message.From, message.To, message.Subject, message.GetMessageBody());
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");
client.Credentials = new System.Net.NetworkCredential("Administrator", "p0046e");
client.Send(mailMessage);
}
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:7,代码来源:MessageService.cs
注:本文中的System.Net.Mail.SmtpClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论