![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//* ---------------------------------
* E-mail 发送接口
* 调用示例
* ---------------------------------
*/
public class webMail
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
-- 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
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
-- declare the interface --#region -- declare the interface --
public string sender
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_sender = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendAccount
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_account = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendPassword
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_password = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendServer
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_server = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendSubject
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_subject = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendBody
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_body = value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public string sendRecv
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
set
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_recv = value;
}
}
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
string sendMail()#region string sendMail()
public string sendMail()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MailMessage mailMessage = new MailMessage();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return "1";
}
catch(Exception ex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ex.Message.ToString();
}
}
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
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)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MailMessage mailMessage = new MailMessage();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SmtpMail.SmtpServer = "www.huabaotrust.com";
SmtpMail.Send(mailMessage);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return "1";
}
catch(Exception ex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ex.Message.ToString();
}
}
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
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)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MailMessage mailMessage = new MailMessage();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SmtpMail.SmtpServer = _server;
SmtpMail.Send(mailMessage);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return "1";
}
catch(Exception ex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ex.Message.ToString();
}
}
#endregion
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
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)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MailMessage mailMessage = new MailMessage();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
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;
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SmtpMail.SmtpServer = server;
SmtpMail.Send(mailMessage);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return "1";
}
catch(Exception ex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ex.Message.ToString();
}
}
#endregion
}
posted @
2007-03-19 23:44
王喆(nasa)
阅读(
452)
评论()
编辑
收藏
举报