Hi All,
I created web appliction to send email using SmtpClient() and MailMessage() objects. When I clicked the button, the message was sent successfully and it just goes to C:\Inetpub\mailroot\Queue directory. Please help me on how to solve this. I am thinking this related to IIS issue? Below is my code.
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(txtFrom.Text, txtFrom.Text);
MailAddress toAddress = new MailAddress(txtTo.Text);
smtpClient.Host = "localhost";
smtpClient.Port = 25;
message.From = fromAddress;
message.To.Add(toAddress);
message.Subject = "Feedback";
message.IsBodyHtml = false;
message.Body = txtMessage.Text;
message.Priority = MailPriority.High;
smtpClient.Send(message);
lblResult.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblResult.Text = "Send Email Failed." + ex.Message;
}Thanks,
Loading
Guest UserPosted Nov 25, 2010, 7:02 AM
Did you got the solution to problem of mails being residing in queue folder.
I am also facing the same problem.
Thanks
Anil
jaypee bacolPosted Jan 11, 2010, 9:21 PM
Thanks for your help. Btw, what if Im going to use local stmp server?
Thanks,
Jaypee
jaypee bacolPosted Jan 10, 2010, 7:02 AM
Thanks for your reply. Unfortunately, it goes thru worst scenario. I got this error.
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.btnSend_Click(Object sender, EventArgs e) in d:\JaypeeUSB\C#\WebApps\Activity1\Default.aspx.cs:line 94
Below is you code that I have modified.
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "secretword");
//client.Credentials = new System.Net.NetworkCredential(txtemail.Text, txtpass.Text);
client.EnableSsl = true;
try
{
MailAddress SendFrom = new MailAddress(txtFrom.Text);
MailAddress SendTo = new MailAddress(txtTo.Text);
message = new MailMessage(SendFrom, SendTo);
message.Body = txtMessage.Text;
message.Subject = "test";
client.Send(message);
lblResult.Text = "eMail Has been sent";
}
catch (Exception ex)
{
lblResult.Text = ex.ToString();
}
Actualy, according to my ISP, my first program is already working since the result when sending is successfully sent. Although, it just goes thru queue root, the reasy why is that I need to have a paid account in yahoo. Please advise.
Thanks,