Click here to Skip to main content
15,898,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
    String strmsg;
    MailAddress fromAddress = new MailAddress( txtEmail.Text, txtName.Text);
    smtpClient.Host = "www.yahoomail.com";
    smtpClient.Port = 25;
    message.From = fromAddress;
    message.To.Add("[DELETED]@yahoo.co.in");
    message.Subject = "Feedback";
    message.IsBodyHtml = true;
    strmsg = "<center><table><tr><td colspan=\"2\"> Client Information:</td></tr> ";
    strmsg += "<tr> <td> Name:</td> <td> " + txtName.Text + "</td></tr>";
    strmsg += "<tr><td>Contact No.:</td><td>" + txtContactNumber.Text + "</td></tr>";
    strmsg += "<tr><td>Email:</td><td>" + txtEmail.Text + "</td></tr>";
    strmsg += "<tr><td>City:</td><td>" + ddlCity.SelectedItem.Text + "</td></tr>";
    strmsg += "<tr><td>Inquery:</td><td>" + txtInquiry.Text + "</td></tr></table></center>";
    message.Body = strmsg;
    smtpClient.Send(message);
    lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
    lblStatus.Text = "Send Email Failed.<br>" + ex.Message;
}


[edit] Title changed to reflect send email problem not receive, code block cleaned up to correct language, Email address removed, tags - OriginalGriff[/edit]
Posted
Updated 19-Aug-10 22:53pm
v2
Comments
OriginalGriff 20-Aug-10 4:54am    
What problem / error do you get?
Sandeep Mewara 20-Aug-10 14:15pm    
What error?

1 solution

I don't see where you specify a username and password, surely yahoo don't let just anyone use their server ?
 
Share this answer
 
Comments
VinodKumar01 20-Aug-10 5:25am    
then tell me how i give username and password

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900