1. using namespaces like that :
using System.Net.Mail;
using System.Net;
2. write code for sending mail and get SMTP server info from web.config:
MailMessage msgObj = new MailMessage();
MailAddress addFrom = new MailAddress(strForm);msgObj.From = addFrom;msgObj.To.Add(strTo);msgObj.Priority = MailPriority.High;
msgObj.Subject = strSubject;msgObj.Body = strBody;msgObj.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings.Get("smtpserver");
smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings.Get("port"));
string Uname = ConfigurationManager.AppSettings.Get("uname");
string password = ConfigurationManager.AppSettings.Get("pass");
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network;smtp.Timeout = 120000;
smtp.EnableSsl = true; // true gor gmail, false for non-SSL
smtp.Credentials = new NetworkCredential(Uname, password);
try
{
smtp.Send(msgObj);
}
catch (Exception ex){throw ex;}
3. write code in web.config inside appsetting tag.
appsettings
add value="smtpservername" key="smtpserver"
add value="25" key="port" !-- port 25 is default, 465 0r 587 for gmail .
add value="username" key="uname">
add value="password" key="pass"
/appsettings
Wednesday, August 26, 2009
Monday, August 10, 2009
print documents without opening MS Word C#
print documents without opening MS Word using C#
1. using namespace in aspx page :
" using System.Diagnostics; "
2. write this on any action control like Button, chkbox etc....
C# Code.....
string filePath = "D:\\Atit\\sample.doc";
ProcessStartInfo info = new ProcessStartInfo(filePath);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
Response.Write("printed !");
finally , build & run ur Apllcation......
1. using namespace in aspx page :
" using System.Diagnostics; "
2. write this on any action control like Button, chkbox etc....
C# Code.....
string filePath = "D:\\Atit\\sample.doc";
ProcessStartInfo info = new ProcessStartInfo(filePath);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
Response.Write("printed !");
finally , build & run ur Apllcation......
Saturday, August 8, 2009
Configuration system failed to initialize
app.config file, tags should be like that....
// app.config start................
1. start "configuration" tag.
2. start "configsection" tag and close "configsection" tag
3. start "appsetting" and close "appsetting" tag.
4. close "configuration" tag.
// end app.config..............
build & run ur Application............
// app.config start................
1. start "configuration" tag.
2. start "configsection" tag and close "configsection" tag
3. start "appsetting" and close "appsetting" tag.
4. close "configuration" tag.
// end app.config..............
build & run ur Application............
Monday, August 3, 2009
add FreeTextBox Control asp.net
By Externally :
1. Add FreeTextBox Control into ToolBox.
2. Add in web.config file this :
3. add folder on ur wesite folder or project folder , when u download a freetextbox.zip file that contain aspnet_client folder.that folder add to ur website folder.
External file : ~/aspnet_client/FreeTextBox/.
4. To add FreeTextBox to an ASP.NET page, do the following:
1. Add the following line to the top of your page:
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
2. Add the following code between tags:
run ur application.....
1. Add FreeTextBox Control into ToolBox.
2. Add in web.config file this :
3. add folder on ur wesite folder or project folder , when u download a freetextbox.zip file that contain aspnet_client folder.that folder add to ur website folder.
External file : ~/aspnet_client/FreeTextBox/.
4. To add FreeTextBox to an ASP.NET page, do the following:
1. Add the following line to the top of your page:
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
2. Add the following code between tags:
run ur application.....
could not load file or assembly FreeTextBox or one of its dependencies the parameter is incorrect exception from hresult 0x80070057 e_invalidar
this link help u to solve your problem :
http://ranafaisal.wordpress.com/2008/03/24/could-not-load-file-or-assembly-ajaxcontroltoolkit-or-one-of-its-dependencies-the-parameter-is-incorrect-exception-from-hresult-0x80070057-e_invalidarg/
http://ranafaisal.wordpress.com/2008/03/24/could-not-load-file-or-assembly-ajaxcontroltoolkit-or-one-of-its-dependencies-the-parameter-is-incorrect-exception-from-hresult-0x80070057-e_invalidarg/
Subscribe to:
Posts (Atom)