Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email

Status
Not open for further replies.

kalkumar

Programmer
Jul 7, 2006
40
US
Hi,
i developed the E-mail application.On SEND button Click i write the following code:
MailMessage msg = new MailMessage();
msg.From = new MailAddress(TextBox1.Text);
string[] to = TextBox2.Text.Split(';');
foreach (string t in to)
{
msg.To.Add(new MailAddress(t));
}
if(TextBox3.Text!="")
{
string[] cc=TextBox3.Text.Split(';');
foreach(string c in cc)
{
msg.CC.Add(new MailAddress(c));
}
}
if (TextBox4.Text != "")
{
string[] bcc = TextBox4.Text.Split(';');
foreach (string b in bcc)
{
msg.Bcc.Add(new MailAddress(b));
}
}
msg.Subject=TextBox5.Text;
msg.Body=TextBox6.Text;
if(RadioButtonList1.SelectedValue=="HTML")
msg.IsBodyHtml=true;
else
msg.IsBodyHtml=false;
SmtpClient sc=new SmtpClient();
sc.Host="localhost";
sc.UseDefaultCredentials=true;
sc.Send(msg);
Response.Redirect("send.aspx");

But the appliaction working.I send mail to Yahoo id.When i opened but there is no message in my Inbox.What is the wrong in the above code.Why there is no message in my inbox.
Thanks In advance.
 
>>But the appliaction working.I send mail to Yahoo id.When i opened but there is no message in my Inbox.What is the wrong in the above code.Why there is no message in my inbox.
Thanks In advance.

email does not get sent immediately. IIS uses SMTP to send the email. from the code i am guessing that you are running this application locally.

therefore in your system go to the mailroot (same folder as there you will find certain folders like queue, bad etc. check and see if the email is there in any one of these folders.

the email's location will tell you as to why the email was not sent. if it is in queue then the server is waiting to send the email...

Known is handfull, Unknown is worldfull
 
Try this chunk of code:-

Email.Body =TextBox.Text;
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
//This object stores the authentication values
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(System.Configuration.ConfigurationSettings.AppSettings["smtpServerUserId"], System.Configuration.ConfigurationSettings.AppSettings["smtpServerPwd"]);
//Put your own, or your ISPs, mail server name onthis next line
mailClient.Host = smtpServerIP;//u can declare these in web.config
mailClient.Port =YourPortNo;;//u can declare these in web.config

mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
mailClient.Send(Email);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top