some time SMPT server did't work.
1.Go to Control Panel -> Administrative tools -> IIS
2. Right Click on the Smtp Server which is at the bottom and select properties.
3. Select the Access Tab.
4.Select the Relay option
5.Check the radio button which says use only listed below and add your localhost address to it which is "127.0.0.1".
or Check the Radio Button All except list below.
i write one code its registration form and at click on Register button that code work and send info to database and send email too. as well as load the thanks page too.
Ganesh@Nilgris:
I am trying to send email based on the article
http://msdn2.microsoft.com/en-us/vbasic/bb630227.aspx
i have added the relavnt namespace but i could get the "smtpserver" and i want the equivalent code in c#
Dim SMTPServer As New SmtpClient("SMTP Server here")
SMTPServer.Send(MyMailMessage)
Any ideas?
************************************************************Code*****************************************************
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Data.OleDb;
using
System.Data.SqlClient;
using
System.Data.ProviderBase;using System.Web.Mail;namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
T6.Text = DateTime.Now.ToString();T7.Text = "Baass new taraining";
}
protected void Button1_Click1(object sender, EventArgs e)
{
string sr = "";
SqlConnection conn = new SqlConnection("Data source=SYED-PC;Initial Catalog=baass;Integrated Security=True");
conn.Open();
sr = "insert into Registrations (Name,Company,Phone,Email,Details,Date,Event,Location,EventCode,EventDate,EventTime) values ('" + Request.Form.Get("T1").ToString() + "','" + Request.Form.Get("T2").ToString() + "','" + Request.Form.Get("T3").ToString() + "','" + Request.Form.Get("T4").ToString() + "','" + Request.Form.Get("T5").ToString() + "','" + Request.Form.Get("T6") + "','"+Request.Form.Get("T7") +"','toronto','Event of 2008','03/15/2008','09:30:00 AM')";
SqlCommand md = new SqlCommand(sr, conn);
int y = md.ExecuteNonQuery();//int x = md.ExecuteNonQuery();
conn.Close();MailMessage mails = new MailMessage();
mails.To = T4.Text;
mails.Bcc = [email protected];
mails.From =
[email protected];mails.Subject = "Registration Detail : " + T1.Text;
mails.Body =
"Welcome " + T1.Text + " " +","+"your Event code is EVENT of march 2008, " +
" Location is: Toronto , " +" Starting Date: Mar,15 2008 at 9:30 am , " +
" If you have any Question Call at: 1800-000-0000 ";SmtpMail.SmtpServer = "localhost";SmtpMail.Send(mails);
Response.Redirect("Thanks.aspx");
}
}
}