Hi
You can do liek this way to send email and connect to SMTP
1. you need know IP address of the SMTP
2. username and password for the access the SMTP
/// <summary></summary><summary></summary>
/// send email from the asp.net with file attachment.
/// <summary></summary><summary></summary>
private void SendEmail()
{
try
{
MailMessage message = new MailMessage();
//from address
message.From = new MailAddress("fromEmailAddress", "Messsage");
// to address
message.To.Add(new MailAddress("ToEmailAddress", "The CodeGain Info"));
// set content email
message.Body = "This is auto generated email dont reply and you have two attachements also";
//set this email content display user inbox like Html format
message.IsBodyHtml = true;
// this is the heading of the email
message.Subject = "The CodeGain.com Message";
SmtpClient emailClient = new SmtpClient("serverIP", 25);// 25 is default for SMTP server
emailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
// set users to default use the default credential
emailClient.UseDefaultCredentials = true;
emailClient.Send(message);
}
catch (SmtpException smtpex)
{
throw smtpex;
}
catch (Exception ex)
{
throw ex;
}
}
Note:Just call this method in your button click or where you need.
more detail can see http://www.codegain.com/index.php?option=com_content&view=article&id=109:send-email-in-aspnet-with-attachment&catid=62:miscellaneous
Thank you
http://www.codegain.com