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" />
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sukesh MarlaPosted Oct 10, 2012, 1:13 PM
New Customer added to the list.";
It will take all details from config automatically
Check this is correct answer if it helped
PunitaPosted Oct 10, 2012, 10:31 PM
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??
PunitaPosted Oct 10, 2012, 10:21 PM
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...
Quang ITPosted Oct 10, 2012, 1:12 PM
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();
}