I write following code in web.config file, now what i need to access following info. while coding?Now what to do to send a mail?? Plz replay.
port="587" userName ="gmailid" password="gmailpassword" />
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sukesh MarlaRank #461 · 5.4K reputationPosted Oct 10, 2012, 9:13 AM EDT
New Customer added to the list.";
It will take all details from config automatically
Check this is correct answer if it helped
Quang IT94 reputationPosted Oct 10, 2012, 9:12 AM EDT
Gi? s? chúng ta mu?n hi?n th? thông tin hai b?ng trên m?t trang web. B?ng th? nh?t luu trong co s? d? li?u SQL Server và b?ng kia luu trong co s? d? li?u MS Access.
T?o file web.config d? luu tr? các chu?i k?t n?i
1) Luu tr? chu?i k?t n?i d?n co s? d? li?u SQL Server:
Ð?i v?i co s? d? li?u SQL Server chúng ta ph?i dùng tên Provider là "System.Data.sqlClient"
2) Luu tr? chu?i k?t n?i d?n co s? d? li?u MS Access
Ð?i v?i co s? d? li?u MS Access chúng ta ph?i vi?t tên Provider là "SystemData.OleDb"
Khi dó, n?i dung c?a file web.config nhu sau:
connectionString="Data Source=INTHIYAAZ;Initial Catalog=shakeer;Persist Security Info=True;User ID=sa;Password=sa"
providerName="System.Data.SqlClient" />
providerName="System.Data.OleDb" />
Khi s? d?ng d? làm vi?c v?i co s? d? li?u trên trang .aspx, chúng ta c?n thêm namespace tuong ?ng
- Ð?i v?i SQL Server:
using System.Data.SqlClient;
Code:
SqlConnection conn ;
conn= new SqlConnection(ConfigurationManager.ConnectionString["textingconnection.Properties.Settings.shakeerConnectionString"].ConnectionString);
conn.Open();
-Ð?i v?i co s? d? li?u MS Access:
using System.Dat.OledClient;
Code:
OleDbConnection conn_MSACCESS;
conn_MSACCESS= new OleDbConnection(ConfigurationManager.ConnectionStrings["MS-db1ConnectionString"].ConnectionString);
conn_MSACCESS.Open();
Khi dó, trong s? ki?n Page_Load c?a trang web s? vi?t nhu sau:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["textingconnection.Properties.Settings.shakeerConnectionString"].ConnectionString);
conn.Open();
Response.Write("connection Connected sucessfully"+
);
conn.Close();
OleDbConnection conn_MSACCESS = new OleDbConnection(ConfigurationManager.ConnectionStrings["MS-db1ConnectionString"].ConnectionString);
conn_MSACCESS.Open();
Response.Write("MS_ACCESS_connection Connected sucessfully");
conn_MSACCESS.Close();
}
Punita73 reputationPosted Oct 10, 2012, 6:21 PM EDT
But what to do to send the attachments??
If i m writting like,
Attachment at = new Attachment("~/TextFile.txt");
mail.Attachments.Add(at);
It gives me this error,
Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\TextFile.txt'.
TextFile.txt is put in current working application...
Punita73 reputationPosted Oct 10, 2012, 6:31 PM EDT
I want to send confirmation code with the email when the user first registers to the site, and then user need to enter that mailed code if both the code matches then user is allowed to login...how to implement it??