asp.net實訓總結
public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
{
System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);
// strSmtpServer是郵箱伺服器
//建立一個郵件伺服器的例項
client.UseDefaultCredentials = false;
//是否隨請求一起傳送
client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
//strFrom發件人的帳號
//strFromPass發件人的密碼
//設定發件人的身份驗證
client.DeliveryMethod = SmtpDeliveryMethod.Network;
//指定如何發郵件
System.Net.Mail.MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody);
//發件人的帳號
//郵件的主題
//郵件的內容
//準備
message.BodyEncoding = System.Text.Encoding.UTF8;
//郵件的正文編碼格式
message.IsBodyHtml = true;
//郵件正文是否是html的格式
client.Send(message);
//傳送郵件
}
如裡你用的是QQ郵件,在傳送郵件的時候,出現瞭如下的錯誤:
《引數或變數中有語法錯誤。 伺服器響應為: mail from address must be same as authorization user》
你就首先應該把QQ
動態從資料庫中取出資料來生成一個三級的導航:(類似於京東左導航)
string str = "select * from Product_Category p1 join son_category s1 on p1.ProductValue=s1.AtCategroy" ;
DataTable table = Class1.executetable(str); //這裡呼叫了一個返回值為 Class1.createlist(table, div1); //呼叫Calss1中的createlist方法table為找到的值的集合,div1為一個前臺的html控制元件
foreach (DataRow item in table.Rows) //遍歷這個table.rows集合
{
div1.InnerHtml += "<div class=sidelist>" + "<span><h3><a href='#'>" + item[1].ToString() + "</h3></span>"; //這裡是生成一級導航
div1.InnerHtml += "<div class='i-list'><ul>"; //生成列表
string[] record = item[5].ToString().Split(';'); //這裡是求出每記錄(所有記錄是串在一起的,’;’表示一條記錄,’:’表示記錄的標題,’,’把記錄中的子標題分開)
foreach (var s1 in record) //第條記錄再進行遍歷
{
div1.InnerHtml += "<li>"; //生成列表
if (s1.LastIndexOf(':') > 0)//判斷這第記錄中是否存在:也就是第二級導航欄位
div1.InnerHtml += s1.Substring(0, s1.LastIndexOf(':')) + "|"; //取出二級欄位
string s11 = s1.Substring(s1.LastIndexOf(':') + 1); //取出二級欄位以後的所有
string[] s2 = s11.Split(','); //再將除二級欄位後的所有用,分開分成資料
foreach (var s3 in s2)
{
div1.InnerHtml += "<a href='leftgogo.aspx?values=" + item[4].ToString() + "'>" + s3 + "</a>|<span>  </span>"; //生成一個超級連並指向一個目標網頁
}
div1.InnerHtml += "</li>";
}
div1.InnerHtml += "</ul></div></div>";
}
無需引用而在整個工程都能用的驗證碼:把這一段程式碼放在一個.aspx中就可以了,在另一個頁面直接放一個Image就可以了
int num = 0;
Bitmap img = new Bitmap(70, 20); //創ä¡ä建¡§畫-布?
using (Graphics g = Graphics.FromImage(img))
{
Random rd = new Random();
num = rd.Next(1000, 9999); //生成1000到9999的隨機數
g.DrawString(num.ToString(), new Font("華a文?琥¨²珀¨º", 16), Brushes.WhiteSmoke, new PointF(0, 0)); //在畫布上畫文字
img.Save(Response.OutputStream, ImageFormat.Gif); //將生成的影像儲存到輸出流中
Session["msg"] = num; //在session中儲存生成的值用以難證使用者輸入驗證碼的正誤!
}
這也算不上是我新學的東西,我覺得在這次實踐中,我不是學到了很多東西,而是我能充分把面向對像的程式設計充分的考慮進來,利用了類,這個的好處可大提高的程式碼的利用率,讓程式寫起來更加的容易。
相關文章
- 中級實訓總結報告
- ASP.NET總結ASP.NET
- 1.23訓練總結
- 今天培訓總結(一)
- 兩日培訓總結
- ASP.NET知識總結ASP.NET
- ASP.Net快取總結ASP.NET快取
- 暑假NOIP集訓6.24~6.29總結
- ASP.Net 管道模型 VS Asp.Net Core 管道 總結ASP.NET模型
- Oracle資料庫實訓後的大三上總結Oracle資料庫
- ASP.NET SingalR 點對點聊天實現思路總結ASP.NET
- 2018Android實驗室CV培訓總結Android
- ASP.NET 2.0 URL Rewrite 學習總結ASP.NET
- web前端培訓React效能優化總結Web前端React優化
- ASP.NET頁面重新整理方法總結ASP.NET
- asp.net定時傳送郵件總結ASP.NET
- 實習總結
- 要創業更要總結:看看前人如何總結創業失敗的教訓創業
- Java培訓總結:過濾器鏈的實現方法、配置和案例分析Java過濾器
- LeetCode演算法訓練-回溯總結LeetCode演算法
- asp.net core 原始碼每日讀 -- Hosting 總結ASP.NET原始碼
- ASP.NET MVC同步和非同步的使用總結ASP.NETMVC非同步
- ASP.NET頁面重新整理方法總結(收藏)ASP.NET
- ASP.NET中的AJAX應用開發總結ASP.NET
- flex實驗總結Flex
- Manila實戰總結
- 實驗一 總結
- halcon——缺陷檢測常用方法總結(特徵訓練)特徵
- Asp.net設定預設按鈕的方法總結ASP.NET
- Asp.net 我的頁面繼承應用總結ASP.NET繼承
- ASP.NET重新整理頁面的六種方法總結ASP.NET
- 告別ASP.NET操作EXCEL的煩惱(總結篇)ASP.NETExcel
- ASP.NET頁面重新整理:自動重新整理頁面的實現方法總結ASP.NET
- 徵文 | 困知勉行,共抵未來—GBase培訓總結與感受
- 【集訓】jzoj 2017.8.10 noip模擬賽A 總結
- 程式碼審查的5點經驗教訓總結
- 【ASP.NET開發】ASP.NET(MVC)三層架構知識的學習總結ASP.NETMVC架構
- React hooks實戰總結ReactHook