My problem is SMTP Server (localhost) sends the email but it sits in the Queue folder.
So I see all my emails are in C:\Inetpub\mailroot\Queue
Any Ideas how can I resolve this ,i developed application using asp.net and c#
for sending email applications.i am using iis6.0,window 2008 r2,what r settings requried in smtp
my code is give below can i provide any setting under smtp?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Web.Mail;
using System.Configuration;
namespace Emailapp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnclick_Click(object sender, EventArgs e)
{
string strFrom=txtfrom .Text.Trim ();
string strTo = txtTo.Text.Trim();
string strCc = txtCc.Text.Trim();
string strSubject = txtSubject.Text.Trim();
string strBody = txtbody .Text .Trim ();
SendEmail(strFrom, strTo, strCc, strSubject, strBody);
}
private void SendEmail(string strFrom, string strTo, string strCc, string strSubject, string strBody)
{
try
{
System.Net.Mail.SmtpClient smtp = null;
System.Net.Mail.MailMessage msg = null;
smtp = new System.Net.Mail.SmtpClient("smtp.mydomain.com");
msg = new System.Net.Mail.MailMessage();
msg.From = new System.Net.Mail.MailAddress(strFrom);
#region To
if (!string.IsNullOrEmpty(strTo.ToString().Trim()))
{
string[] sTo = strTo.ToString().Split(';');
for (int i = 0; i < sTo.Length; i++)
{
if ((sTo[i].ToString().IndexOf('@') != -1) && (sTo[i].ToString().IndexOf('.') != -1))
msg.To.Add(new System.Net.Mail.MailAddress(sTo[i].ToString()));
}
}
#endregion To
#region Cc
if (!string.IsNullOrEmpty(strCc.ToString().Trim()))
{
string[] sCc = strCc.ToString().Split(';');
for (int i = 0; i < sCc.Length; i++)
{
if ((sCc[i].ToString().IndexOf('@') != -1) && (sCc[i].ToString().IndexOf('.') != -1))
msg.CC.Add(new System.Net.Mail.MailAddress(sCc[i].ToString()));
}
}
#endregion Cc
msg.Subject = strSubject;
msg.Body = strBody;
msg.IsBodyHtml = true;
smtp.Send(msg);
Response.Write("Your Email has been sent sucessfully");
}
catch (Exception ee)
{
Response .Write ("failour message"+ee.ToString ());
}
}
}
}