主頁 > 知識庫 > asp.net發(fā)郵件示例

asp.net發(fā)郵件示例

熱門標(biāo)簽:柳州電銷機器人公司 昆明語音電銷機器人價格 征途美甲店地圖標(biāo)注 太原400電話上門辦理 騰訊地圖標(biāo)注手機 浦發(fā)電話機器人提醒還款 400電話如何申請取消 電銷語音機器人型號參數(shù) 百度地圖怎樣做地圖標(biāo)注

復(fù)制代碼 代碼如下:

protected void SendMail()
{
try
{
string CreaterName = "";
string examiner = "";
Liststring> mailList = GetMailList(ref CreaterName, ref examiner);

MailEntity me = new MailEntity();
MailEntity me_1 = new MailEntity();

me.AddresserMail = ConfigurationManager.AppSettings["AddresserMail"].ToString();
me.AddresserName = ConfigurationManager.AppSettings["AddresserName"].ToString();
me.AddresserPwd = ConfigurationManager.AppSettings["AddresserPwd"].ToString();

me_1.AddresserMail = ConfigurationManager.AppSettings["AddresserMail_1"].ToString();
me_1.AddresserName = ConfigurationManager.AppSettings["AddresserName_1"].ToString();
me_1.AddresserPwd = ConfigurationManager.AppSettings["AddresserPwd_1"].ToString();

string strPostfix = ConfigurationManager.AppSettings["Postfix"].ToString();
string isSend = ConfigurationManager.AppSettings["isSend"].ToString();
StringBuilder ss = new StringBuilder();
if (isSend == "1")
{
if (mailList.Count > 0)
{
foreach (string mail in mailList)
{
int count = mail.IndexOf("@");
string postfix = mail.Substring(count + 1);

string[] pf = strPostfix.Split(new char[] { '|' });
int pCount = 0;
foreach (string p in pf)
{
if (postfix == p)
{
pCount++;
break;
}
}
if (pCount > 0)
{
me.AddresseeMail = mail.ToString();
}
else
{
me_1.AddresseeMail = mail.ToString();
}
string Body = "";

try
{
using (StreamReader sr = new StreamReader(HttpRuntime.BinDirectory + "/../tpl/tpl_Debt.htm", System.Text.Encoding.Default))
{
Body = sr.ReadToEnd();
}
}
catch (Exception ex)
{
lbMessage.Text = "*** 讀取模板出錯(reading template failed)!" + ex.Message;
lbMessage.ForeColor = System.Drawing.Color.Red;
return;
}

// --------------------------------------------------------------------------
me.ClientHost = ConfigurationManager.AppSettings["clientHost"].ToString();
me.MailEncoding = System.Text.Encoding.GetEncoding("GB2312");
me.MailPriority = System.Net.Mail.MailPriority.Normal;
me.IsBodyHtml = true;
me.Subject = "[" + CreaterName + "]創(chuàng)建的借款單";
//--------------------------------------------------------------------------
me_1.ClientHost = ConfigurationManager.AppSettings["clientHost_1"].ToString();
me_1.MailEncoding = System.Text.Encoding.GetEncoding("GB2312");
me_1.MailPriority = System.Net.Mail.MailPriority.Normal;
me_1.IsBodyHtml = true;
me_1.Subject = "[" + CreaterName + "]創(chuàng)建的借款單";

Body = Body.Replace("DTTPL_COMM_MODULE_NAME_ExpenseName", CreaterName);//借款人
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Type", ddlDebtType_Add.SelectedItem.Text);//借款類型
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Money", txbMoney_Add.Text);//金額
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Mender", txtMender.Text);//審核人
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Time", tbxDebtTime_Add.Text);//借款時間
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Advance", tbAdvance.Text);//代/墊款單位
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_DebtPathWay", ddlDebtPathWay.SelectedItem.Text);//借款方式
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Remark", txbMemo_Add.Text);//借款事由
// Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Mend", "");//審核意見
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_Memo", "");//備注
string url = HttpContext.Current.Request.Url.AbsoluteUri;
url = url.Replace("http://", "");
int index = url.IndexOf("/");
url = "http://" + url.Substring(0, index + 1);
Body = Body.Replace("DTTPL_COMM_MODULE_NAME_LINK", url + "Affair/SelectWorkEvent.aspx?typeid=249");


me.Body = Body;
me_1.Body = Body;

if (me.AddresseeMail == null me.CopyToAddresseeMail == null me_1.AddresseeMail == null me_1.CopyToAddresseeMail == null)
{
lbMessage.Text = "*** 借款單保存成功! 但責(zé)任人/關(guān)注人因在數(shù)據(jù)庫沒有存郵箱地址,郵件未曾發(fā)送!";
lbMessage.ForeColor = System.Drawing.Color.Red;
return;
}
if (me.AddresseeMail != null || me.CopyToAddresseeMail != null)
{
bool temp = false;
for (int y = 0; y 3; y++)
{
try
{
if (MailServer.SendMail(me))
{
temp = true;
break;
}
}
catch (Exception ex)
{
continue;
}

}
if (!temp)
{
if (me.AddresseeMail != null)
{
ss.Append(me.AddresseeMail.Trim());
}
if (me.CopyToAddresseeMail != null me.CopyToAddresseeMail.Trim() != "")
{
ss.Append(",");
ss.Append(me.CopyToAddresseeMail.Trim());
}
}
me.AddresseeMail = null;
}
if (me_1.AddresseeMail != null || me_1.CopyToAddresseeMail != null)
{
bool temp = false;
for (int y = 0; y 3; y++)
{
try
{
if (MailServer.SendMail(me_1))
{
temp = true;
break;
}
}
catch (Exception ex)
{
continue;
}
}
if (!temp)
{
if (ss.ToString().Trim() != "")
{
ss.Append(",");
if (me_1.AddresseeMail != null)
ss.Append(me_1.AddresseeMail.Trim());
if (me_1.CopyToAddresseeMail != null me_1.CopyToAddresseeMail.Trim() != "")
{
ss.Append(",");
ss.Append(me_1.CopyToAddresseeMail.Trim());
}
}
else
{
if (me_1.AddresseeMail != null)
ss.Append(me_1.AddresseeMail.Trim());
if (me_1.CopyToAddresseeMail != null me_1.CopyToAddresseeMail.Trim() != "")
{
ss.Append(",");
ss.Append(me_1.CopyToAddresseeMail.Trim());
}
}
}
me_1.AddresseeMail = null;
}
}
}
}
}
catch (Exception ex)
{
lbMessage.Text = "*** 發(fā)送失敗(the email is not sent)!" + ex.ToString();
lbMessage.ForeColor = System.Drawing.Color.Red;
}
}

您可能感興趣的文章:
  • ASP用JMail、CDO發(fā)送郵件
  • Jmail組件發(fā)送郵件之絕對能用的函數(shù)
  • asp jmail發(fā)郵件 詳細(xì)解析
  • 用asp實現(xiàn)網(wǎng)址和郵件地址的轉(zhuǎn)換函數(shù)
  • asp.net2.0實現(xiàn)郵件發(fā)送(測試成功)
  • Jmail 圖文安裝教程 asp在線發(fā)送郵件組件
  • ASP.Net郵箱發(fā)郵件實例代碼
  • .net jMail郵件發(fā)送(含抄送、密送、多發(fā)、日志記錄)實例代碼
  • asp.net發(fā)郵件的幾種方法匯總
  • Jmail發(fā)送郵件與帶附件亂碼解決辦法分享
  • asp.net發(fā)送郵件示例分享
  • asp.net發(fā)送郵件實現(xiàn)方法
  • asp+JMAIL實現(xiàn)發(fā)送郵件

標(biāo)簽:陽泉 新疆 江蘇 天門 德陽 張家界 蘭州 白山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net發(fā)郵件示例》,本文關(guān)鍵詞  asp.net,發(fā),郵件,示例,asp.net,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net發(fā)郵件示例》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net發(fā)郵件示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章