How can you Earn 30 Dollar Daily ? Click to see the Earning Ways.
Login(Email) Password Forgot Password
Home ASP.net System Info C# Books Java Script Visual C++(MFC) C/C++ Win API Java Contact Us
Browse Category
Send Email with username and password  in asp.net using C#  in .net Framework 1.1(Server Authentication)
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!");
Send Emails in ASP.NET 2.0 with server Authentication
Sending emails from ASP.NET 2.0 application is made very simply using MailMessage and SmtpClient classes available in System.Net.Mail namespace in .NET Framework. Sometimes SMTP server required authentication information of email client to send emails.
You need to import System.Net.Mail and System.Net namespaces to test following code.
C#
string mailFrom = "webmaster@itworld2.com";
string mailTo = "webmaster@itworld2.com";
MailAddress from = new MailAddress(mailFrom , "ItWorld"); // here you will mention your display name
MailAddress to = new MailAddress(mailTo);
//Create Mail Message Object
MailMessage mm = new MailMessage(from, to);
string subject = "Hello";
string messageBody = "This is the test email ";
mm.Subject = subject ;
mm.IsBodyHtml = true;
mm.Body = messageBody ;
// Create SmtpClient class to Send Message
SmtpClient smtp = new SmtpClient();
// Here you specify your smtp host address such as mail.itworld2.com or IP address of the email server// Specify that you dont want to use default credentials
smtp.UseDefaultCredentials = false;
// Create user credentials by using NetworkCredential class="comments"> // Create user credentials by using NetworkCredential class

NetworkCredential credential = new NetworkCredential();
credential.UserName="itworld1"; // here you will write the usernamecredential.Password = "abc123";
smtp.Credentials = credential;
smtp.Send(mm);

Authenticate with SMTP server before sending email in java
You need activation.jar, smtp.jar, and mailapi.jar in your classpath for this to work.
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
public class MailWithPasswordAuthentication
{
public static void main(String[] args) throws MessagingException
{
new MailWithPasswordAuthentication().run();
}
private void run() throws MessagingException
{ Message message = new MimeMessage(getSession());
message.addRecipient(RecipientType.TO, new InternetAddress("to@example.com"));
message.addFrom(new InternetAddress[] { new InternetAddress("from@example.com") });
message.setSubject("the subject");
message.setContent("the body", "text/plain"); Transport.send(message);
}
private Session getSession()
{
Authenticator authenticator = new Authenticator();
Properties properties = new Properties();
properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName()); properties.setProperty("mail.smtp.auth", "true"); properties.setProperty("mail.smtp.host", "mail.example.com"); properties.setProperty("mail.smtp.port", "25"); return Session.getInstance(properties, authenticator);
}
private class Authenticator extends javax.mail.Authenticator
 {
private PasswordAuthentication authentication;
public Authenticator()
 {
String username = "auth-user";
String password = "auth-password";
authentication = new PasswordAuthentication(username, password);
}
 protected PasswordAuthentication getPasswordAuthentication()
{
 return authentication;


}
 }
}

Sending Mail from PHP Using SMTP Authentication - Example

<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@domainname.com>";
$to = "Ramona Recipient <recipient@domainname.com>";
$subject = "Hello";
$body = "Hi,\n\Test email";

$host = "mail.domainname.com";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>
"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." 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