| Send Email with username and password against email
server in asp.net using C# |
public static void SendMail(string
smtpServer, int nPort, string
UserName, string Password,
string FromName, string FromEmail,
string ToEmail, string
Header, string Message )
{
System.Web.Mail.MailMessage Mail = new System.Web.Mail.MailMessage();
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver
"] = smtpServer;
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing
"] = 2;
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport
"] = nPort.ToString();
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"] = 1;
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername
"] = UserName;
Mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword
"] = Password;
Mail.To = ToEmail;
Mail.From = FromEmail;
Mail.Subject = Header;
Mail.Body = Message;
Mail.BodyFormat = System.Web.Mail.MailFormat.Html;
System.Web.Mail.SmtpMail.SmtpServer = smtpServer;
System.Web.Mail.SmtpMail.Send(Mail);
}
|
| This is way how you will call function |
SendMail("mail.itworld2.com", 25, "webmaster@yourdomain.com",
"passwordhere", "Name here",
"youremail@yourdomain.com", "receieveremail@domain.com", "Subject", "How
are you?
I am fine!"); |
|
| "Error while trying to run project:Unable to start debugging on the web
server. You do not have permission to debug the application. The URL for this
project is in the Internet zone."
|
| This is the procedure how can you remove this error. |
1. In the Internet Explorer, "Tools" Menu, select
"Internet Options".
2. Switch to "Security" Tab.
3. Click on "Internet" (The Globe Icon. Its actually the default selected).
4. Click on "Custom Level" in the bottom.
5. Scroll down to find the "User Authentication" section.
6. Select "Automatic logon with current username and password".
7. Click "Ok" twice to exit.
|
|
|
| How to make a default button in
ASP.NET |
We need to specify exactly what button will be "cliked" when
visitor press Enter key, according to what textbox currently has a focus. The
solution could be to add onkeydown attribute to textbox control:
| TextBox1.Attributes.Add("onkeydown",
"if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode ==
13)) {document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; "); |
This line of code will cause that button Button1 will be "clicked" when visitor
press Enter key and cursor is placed in TextBox1 textbox. On this way you can
"connect" as many text boxes and buttons as you want
Note: Place one TextBox named as TextBox1 ,a Button named as
Button1 and put above code in the form load event.
|
| How you can get the domain name from URL Request Object? |
| If you want to get domain name of a url you have to use
Request.Servervariables["HTTP_HOST"] in C# ASP.net |
|
|