记录一个发邮件的cs文件
/**//* ---------------------------------
* E-mail 发送接口
* 调用示例
* ---------------------------------
*/
public class webMail
{
-- declare the variables --#region -- declare the variables --
private string _sender = "";
private string _account = "";
private string _password = "";
private string _server = "";
private string _subject = "";
private string _body = "";
private string _recv = "";
#endregion
-- declare the interface --#region -- declare the interface --
public string sender
{
set
{
_sender = value;
}
}
public string sendAccount
{
set
{
_account = value;
}
}
public string sendPassword
{
set
{
_password = value;
}
}
public string sendServer
{
set
{
_server = value;
}
}
public string sendSubject
{
set
{
_subject = value;
}
}
public string sendBody
{
set
{
_body = value;
}
}
public string sendRecv
{
set
{
_recv = value;
}
}
#endregion
string sendMail()#region string sendMail()
public string sendMail()
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", _account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", _password);
mailMessage.From = _sender;
mailMessage.To = _recv;
mailMessage.Subject = _subject;
mailMessage.Body = _body;
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string testSend(string sender,string subject,string body,string recv)#region string testSend(string sender,string subject,string body,string recv)
public string testSend(string sender,string subject,string body,string recv)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "kefu@huabaoTrust.com");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456");
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = "www.huabaotrust.com";
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv)#region string sendMail(string sender,string subject,string body,string recv)
public string sendMail(string sender,string subject,string body,string recv)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", _account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", _password);
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)#region string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
public string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
}
* E-mail 发送接口
* 调用示例
* ---------------------------------
*/
public class webMail
{
-- declare the variables --#region -- declare the variables --
private string _sender = "";
private string _account = "";
private string _password = "";
private string _server = "";
private string _subject = "";
private string _body = "";
private string _recv = "";
#endregion
-- declare the interface --#region -- declare the interface --
public string sender
{
set
{
_sender = value;
}
}
public string sendAccount
{
set
{
_account = value;
}
}
public string sendPassword
{
set
{
_password = value;
}
}
public string sendServer
{
set
{
_server = value;
}
}
public string sendSubject
{
set
{
_subject = value;
}
}
public string sendBody
{
set
{
_body = value;
}
}
public string sendRecv
{
set
{
_recv = value;
}
}
#endregion
string sendMail()#region string sendMail()
public string sendMail()
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", _account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", _password);
mailMessage.From = _sender;
mailMessage.To = _recv;
mailMessage.Subject = _subject;
mailMessage.Body = _body;
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string testSend(string sender,string subject,string body,string recv)#region string testSend(string sender,string subject,string body,string recv)
public string testSend(string sender,string subject,string body,string recv)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "kefu@huabaoTrust.com");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456");
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = "www.huabaotrust.com";
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv)#region string sendMail(string sender,string subject,string body,string recv)
public string sendMail(string sender,string subject,string body,string recv)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", _account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", _password);
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)#region string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
public string sendMail(string sender,string subject,string body,string recv,string server,string account,string password)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", account);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
mailMessage.From = sender;
mailMessage.To = recv;
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpMail.SmtpServer = server;
SmtpMail.Send(mailMessage);
return "1";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
}
#endregion
}