本文整理汇总了C#中System.Web.Mail.MailMessage类的典型用法代码示例。如果您正苦于以下问题:C# MailMessage类的具体用法?C# MailMessage怎么用?C# MailMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MailMessage类属于System.Web.Mail命名空间,在下文中一共展示了MailMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendEmail
private static void SendEmail( string filePath )
{
Console.Write( "Crash: Sending email..." );
try
{
MailMessage message = new MailMessage();
message.Subject = "Automated RunUO Crash Report";
message.From = "RunUO";
message.To = Emails;
message.Body = "Automated RunUO Crash Report. See attachment for details.";
message.Attachments.Add( new MailAttachment( filePath ) );
SmtpMail.SmtpServer = EmailServer;
SmtpMail.Send( message );
Console.WriteLine( "done" );
}
catch
{
Console.WriteLine( "failed" );
}
}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:25,代码来源:CrashGuard.cs
示例2: SendMail
/// <summary>
/// Generic function to send mail
/// </summary>
/// <param name="smtpServer">SMTP Server Name/IP</param>
/// <param name="from">From Email Address</param>
/// <param name="to">To Email Address</param>
/// <param name="subject">Subject</param>
/// <param name="body">Body</param>
/// <returns>bool</returns>
public bool SendMail(string strSmtpServer, string strFrom, string strTo, string strSubject, string strBody)
{
MailMessage mailMsg = null;
Boolean blnMailSent = false;
try
{
mailMsg = new MailMessage();
mailMsg.From = strFrom;
mailMsg.To = strTo;
mailMsg.Cc = strFrom;
mailMsg.Subject = strSubject;
mailMsg.BodyFormat = MailFormat.Html;
mailMsg.Body = strBody;
if (strSmtpServer.Trim().Length != 0)
{
SmtpMail.SmtpServer = strSmtpServer;
}
SmtpMail.Send(mailMsg);
blnMailSent = true;
}
catch (Exception ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex, Global .EXCEPTION_POLICY);
if (rethrow)
throw;
}
return blnMailSent;
}
开发者ID:BInny1,项目名称:United-Car-Exchange,代码行数:40,代码来源:Utility.cs
示例3: btnForgotpass_Click
private void btnForgotpass_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if (Page.IsValid)
{
if (this.emailNotification)
{
BLUser wUser = new BLUser();
wUser.EMail = txtEMail.Text.Trim().ToLower();
wUser.Retrieve();
if (wUser.ID>0 && wUser.Enabled)
{
StringWriter writer = new StringWriter();
Server.Execute("email/emailForgotPass.aspx?email="+wUser.EMail, writer);
string strhtmlbody = writer.ToString();
// Response.Write(strhtmlbody);
// Response.End();
MailMessage objMailMessage = new MailMessage();
objMailMessage.Subject = siteName+": your password";
objMailMessage.From = this.emailNotificationCustomerFrom;
objMailMessage.To = wUser.EMail;
objMailMessage.Cc = this.emailNotificationCustomerCc;
objMailMessage.Bcc = this.emailNotificationCustomerBcc;
objMailMessage.Body = strhtmlbody;
objMailMessage.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = this.smtpServer;
SmtpMail.Send( objMailMessage );
}
}
Response.Redirect(".?page=login");
}
}
开发者ID:elieli,项目名称:nonProfit,代码行数:31,代码来源:forgotpass.ascx.cs
示例4: SendMail
public static void SendMail(string to, string bbc, string subject, string messages, string smtp, string port, string from, string user, string password)
{
try
{
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = to;
mail.Bcc = bbc;
mail.From = from;
mail.Subject = subject;
mail.BodyEncoding = Encoding.GetEncoding("utf-8");
mail.BodyFormat = MailFormat.Html;
mail.Body = messages;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = smtp;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = port;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"] = 1; // "true";
//mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"] = 60;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = user;
mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;
//SmtpMail.SmtpServer = smtp;
SmtpMail.Send(mail);
}
catch (Exception ex)
{
throw;
}
}
开发者ID:HoangNgocThin,项目名称:thietbimoitruong,代码行数:28,代码来源:MailSender.cs
示例5: EmailBodyGeneral
public void EmailBodyGeneral(string toEmail, string subject, string txt)
{
try
{
MailMessage objMail = new MailMessage();
objMail.From = "EHR <[email protected]>";
objMail.To = toEmail;
objMail.Subject = subject;
objMail.BodyFormat = MailFormat.Html;
objMail.Body = txt;
SmtpMail.SmtpServer = "wczmail.wistron.com";
SmtpMail.Send(objMail);
}
catch (Exception e)
{
MailMessage objMail = new MailMessage();
objMail.From = "EHR <[email protected]>";
objMail.To = "EHR <[email protected]>";
objMail.Subject = subject;
objMail.BodyFormat = MailFormat.Html;
objMail.Body = "Email not deliver. <br />Did not deliver to: " + toEmail + e.Message;
SmtpMail.SmtpServer = "wczmail.wistron.com";
SmtpMail.Send(objMail);
}
}
开发者ID:rheaprokop,项目名称:EHR-Recruitment,代码行数:25,代码来源:QueryOleDB.cs
示例6: SenddMail
/// <summary>
/// �����ʼ�
/// </summary>
/// <Author>Terminate</Author>
/// <CreateTime>2006-10-1</CreateTime>
/// <param name="MailFrom">������[�����˵�ַ]</param>
/// <param name="MailTo">�����˵�ַ</param>
/// <param name="MailSubject">�ż�����</param>
/// <param name="MailBody">�ż�����</param>
public static void SenddMail(string MailFrom,string MailTo,string MailSubject,string MailBody)
{
string SmtpServer,UserName,UserPwd;
bool MailCheck;
SmtpServer="mail.hbu.cn";
UserName="haodongliang";
UserPwd="[email protected]";
MailCheck=true;
MailMessage MailObj=new MailMessage();
SmtpMail.SmtpServer=SmtpServer;
if(MailCheck)
{
//��֤
MailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");//��֤��ʽ1��֤��0����֤
//�û���
MailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",UserName);
//����
MailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",UserPwd);
}
MailObj.From =MailFrom; //������
MailObj.To =MailTo; //�ռ���
MailObj.Subject =MailSubject; //�ʼ�����
MailObj.Priority =MailPriority.High; //�ʼ��ȼ�
MailObj.BodyFormat =MailFormat.Html; //�ʼ����ݸ�ʽ
MailObj.Body =MailBody; //�ʼ�����
SmtpMail.Send(MailObj);
}
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:37,代码来源:obMail.cs
示例7: Send
/// <summary>Envia um mail</summary>
public static bool Send( MailMessage message )
{
try {
if( message.From == null || message.From == "" ) {
message.From = Mailer.From;
}
#if DEBUG_MAIL
Log.log("----- SEND MAIL DEBUG ----------");
Log.log("To: {0}", message.To);
Log.log("From: {0}", message.From);
Log.log("Bcc: {0}", message.Bcc);
Log.log("Title: {0}", message.Subject);
Log.log("Message: {0}", message.Body);
Log.log("-------------------------------");
#endif
Log.log("Sending mail message '{0}'...", message.Subject );
SmtpMail.Send(message);
Log.log("... Done!");
return true;
} catch(System.Exception e) {
ExceptionLog.log(e, false);
return false;
}
}
开发者ID:zi-yu,项目名称:orionsbelt,代码行数:28,代码来源:Mailer.cs
示例8: SendMailMessage
/// <summary>
/// �����ʼ�
/// </summary>
/// <param name="to"></param>
/// <param name="from"></param>
/// <param name="subject"></param>
/// <param name="message"></param>
/// <param name="isAsync"></param>
private void SendMailMessage(string to, string from, string subject, string message, bool isAsync)
{
if (string.IsNullOrWhiteSpace(to))
throw new ArgumentNullException("to");
if (string.IsNullOrWhiteSpace(from))
throw new ArgumentNullException("from");
if (string.IsNullOrWhiteSpace(subject))
throw new ArgumentNullException("subject");
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = from;
mailMessage.To = to;
mailMessage.Subject = subject;
mailMessage.Body = message;
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8; //�ʼ����ݱ���
SmtpMail.SmtpServer = this.SmtpServer; // �����ʼ��������˿�
//��֤
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //�Ƿ���Ҫ��֤��һ����Ҫ��
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //�Լ�������û���
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //�Լ����������
SmtpMail.Send(mailMessage);
}
catch (Exception ex)
{
throw new Exception("�����ʼ�����", ex);
}
}
开发者ID:ahui2012,项目名称:CommonTools,代码行数:40,代码来源:DotNetWebMail.cs
示例9: button1_Click
private void button1_Click(object sender, System.EventArgs e)
{
if (boxFrom.Text == defaultFrom || boxFrom.Text.Split('@').Length != 2)
{
MessageBox.Show("Please enter your email address.");
return;
}
Hide();
MailMessage msg = new MailMessage();
msg.From = boxFrom.Text;
msg.To = boxEmailTo.Text;
msg.Subject = "NoxMapEditor Crash Report";
msg.Body = boxMessage.Text + (boxNotes.Text == "" ? "" : "\n\nNotes:\n" + boxNotes.Text);
bool sent = false;
foreach (string server in DnsLib.DnsApi.GetMXRecords(boxEmailTo.Text.Split('@')[1]))
{
SmtpMail.SmtpServer = server;
try
{
SmtpMail.Send(msg);
sent = true;
break;
}
catch (Exception) {}
}
if (!sent)
MessageBox.Show("Couldn't send mail message.");
}
开发者ID:elitak,项目名称:NoxTools,代码行数:31,代码来源:ExceptionDialog.cs
示例10: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
if ((tbxPhone.Text == "") && (tbxEmail.Text == ""))
{
CustomValidator1.IsValid = false;
}
else
{
SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
MailMessage mm;
mm = new MailMessage();
mm.BodyFormat = MailFormat.Html;
mm.To = "[email protected]";
mm.From = "[email protected]";
mm.Subject = "New message generated from 1PromotionalProducts.com";
mm.Body = "*** THIS IS AN AUTOMATED EMAIL. DO NOT REPLY. ***<br /><br />";
mm.Body += "Name: " + tbxName.Text;
if (tbxEmail.Text != "")
{
mm.Body += "<br /><br />Reply Email: " + tbxEmail.Text;
}
if (tbxPhone.Text != "")
{
mm.Body += "<br /><br />Phone Number: " + tbxPhone.Text;
}
mm.Body += "<br /><br />Comment/Question:<br />" + tbxBody.Text.Replace("\r", "<br />").Replace("\n", "");
SmtpMail.Send(mm);
Response.Redirect("Default.aspx", true);
}
}
开发者ID:chevex-archived,项目名称:1PromotionalProducts,代码行数:33,代码来源:ContactUs.aspx.cs
示例11: Send
public static String Send(StringBuilder strbBodyParam, String strSubjectParam,
String strEmailAddrParam)
{
String strCurrentStatus = "";
// prepare message with the report
MailMessage mmEmailMsg = new MailMessage();
mmEmailMsg.Body = strbBodyParam.ToString();
mmEmailMsg.From = SenderEmailAddr;
mmEmailMsg.Subject = strSubjectParam;
mmEmailMsg.To = strEmailAddrParam;
// send email with the report
// DirectSMTP.SmtpServer = "10.10.10.30";
// DirectSMTP.SmtpServer = "smtpgtwy.emcare.com";
// Changed SMTP server - 6/21/07, grf
//
DirectSMTP.SmtpServer = SmtpServerAddr;
String strResponse = DirectSMTP.Send(mmEmailMsg);
if (!strResponse.Equals(""))
{
strCurrentStatus = String.Format(
"ERROR: Could not send email to {0} through {1}\r\n\r\n{2}.",
strEmailAddrParam, DirectSMTP.SmtpServer, strResponse);
}
else
{
strCurrentStatus = String.Format("Sent report to email {0}", strEmailAddrParam);
}
return strCurrentStatus;
}
开发者ID:fmendes,项目名称:SMTPClass,代码行数:32,代码来源:SMTPClasses.cs
示例12: Sendmail
public static void Sendmail(string emailTo, string subject, string body)
{
try
{
string smtpAddress = "smtp.fairygroup.co.th";
int portNumber = 25;
bool enableSSL = true;
string emailFrom = "[email protected]";
string password = "[email protected]";
//string emailTo = conf.ConfigValue;
MailMessage Message = new MailMessage();
Message.To = password;
Message.From = emailFrom;
Message.Subject = subject;
Message.Body = body;
SmtpMail.SmtpServer = "smtp.fairygroup.co.th";
SmtpMail.Send(Message);
}
catch (System.Web.HttpException ehttp)
{
throw ehttp;
//Console.WriteLine("{0}", ehttp.Message);
//Console.WriteLine("Here is the full error message output");
//Console.Write("{0}", ehttp.ToString());
}
}
开发者ID:Jajara,项目名称:FairyGroup,代码行数:29,代码来源:SendmailLib.cs
示例13: SendExceptionMail
public static void SendExceptionMail(string strMessage, string strSource, string strStackTrace)
{
try
{
string strFromMailId = ConfigurationManager.AppSettings.Get("EmailFrom");
string strMailServer = ConfigurationManager.AppSettings.Get("SmtpClient");
string strMailUser = ConfigurationManager.AppSettings.Get("UID");
string strMailPwd = ConfigurationManager.AppSettings.Get("Pwd");
string vstrSubject = "CSWeb Integration - Exception";
string vstrBody = "<b>Message: </b>" + strMessage + "<br/><br/><b>Sourse: </b>" + strSource + "<br/><br/><b>StackTrace: </b>" + strStackTrace;
string strMails = ConfigurationManager.AppSettings.Get("ErrorEmailTo");
MailMessage objMessage = new MailMessage();
if (strMailServer != "")
{
SmtpMail.SmtpServer = strMailServer;
objMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
objMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = strMailUser;
objMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = strMailPwd;
}
objMessage.From = strFromMailId;
objMessage.To = strMails;
objMessage.Subject = vstrSubject;
objMessage.Body = vstrBody;
objMessage.BodyFormat = MailFormat.Html;
SmtpMail.Send(objMessage);
}
catch (Exception exc)
{
}
}
开发者ID:xyzthought,项目名称:iBeyondZ,代码行数:33,代码来源:SendMail.cs
示例14: ButtonSubmit_Click
protected void ButtonSubmit_Click(object sender, System.EventArgs e)
{
Server.ScriptTimeout = 1000;
Response.Flush();
SmtpMail.SmtpServer = "localhost";
MailMessage mail = new MailMessage();
mail.To = this.TextBoxTo.Text;
mail.Cc = this.TextBoxCc.Text;
mail.Bcc = this.TextBoxBcc.Text;
mail.From = this.TextBoxFrom.Text;
mail.Subject = this.TextBoxSubject.Text;
mail.Body = this.TextBoxBody.Text;
try
{
SmtpMail.Send(mail);
Response.Write("<p><strong> The Mail has been sent to: </strong></p>");
Response.Write("• To: " + mail.To + "</br>");
Response.Write("• Cc: " + mail.Cc + "</br>");
Response.Write("• Bcc: " + mail.Bcc + "</br>");
}
catch(System.Exception ex)
{
Response.Write("<p><strong>An erros has occured: " + ex.Message + "</strong><p>");
}
Response.Flush();
}
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:29,代码来源:WebForm1.aspx.cs
示例15: SendMessage
internal virtual void SendMessage(MailMessage message)
{
lock (emailLock)
{
SmtpMail.SmtpServer = configurationData.SmtpServer;
SmtpMail.Send(message);
}
}
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:EmailMessage.cs
示例16: Main
public static void Main(string[] args)
{
if (args.Length < 5 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
{
Console.WriteLine(usage);
}
else
{
try
{
string server = args[0];
string to = args[1];
string from = args[2];
string subject = args[3];
string body = args[4];
string[] attachments = null;
if (args.Length > 5)
{
attachments = new string[args.Length - 5];
for (int i = 0; i < attachments.Length; i++)
{
attachments[i] = args[5 + i];
}
}
MailMessage myMail = new MailMessage();
myMail.To = to;
myMail.From = from;
myMail.Subject = subject;
myMail.Body = body;
if (attachments != null)
{
foreach (string file in attachments)
{
if (File.Exists(file))
{
string filePath = Path.GetFullPath(file);
myMail.Attachments.Add(new MailAttachment(filePath, MailEncoding.Base64));
}
else
throw new Exception("File "+file+" cannot be attached");
}
}
SmtpMail.SmtpServer = server;
SmtpMail.Send(myMail);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
return;
}
Console.WriteLine("Message has been sent");
}
}
开发者ID:Diullei,项目名称:Storm,代码行数:57,代码来源:SMTPMailTo.cs
示例17: NotifyUser
public virtual void NotifyUser(string user, string msg)
{
MailMessage mail = new MailMessage();
mail.From = from;
mail.To = user;
mail.Subject = msg;
mail.Body = msg;
SmtpMail.Send(mail);
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:Notifier.cs
示例18: NotifyAdmin
public virtual void NotifyAdmin(string msg)
{
MailMessage mail = new MailMessage();
mail.From = from;
mail.To = admin;
mail.Subject = msg;
mail.Body = msg;
SmtpMail.Send(mail);
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:Notifier.cs
示例19: Send
public virtual void Send(string from, string to, string subject, string messageText)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = from;
mailMessage.To = to;
mailMessage.Subject = subject;
mailMessage.BodyFormat = MailFormat.Html;
mailMessage.Body = messageText;
SmtpMail.Send(mailMessage);
}
开发者ID:vardars,项目名称:ci-factory,代码行数:10,代码来源:EmailGateway.cs
示例20: MailImages
public MailImages (IBrowsableCollection collection)
{
message = new MailMessage ();
message.From = "[email protected]";
message.To = "[email protected]";
message.Subject = "test";
EsmtpMail mail = new EsmtpMail ("smtp.gmail.com", "lewing", "ricedream");
mail.Send (message)
}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:10,代码来源:MailDialog.cs
注:本文中的System.Web.Mail.MailMessage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论