Mittal Joshi

Mittal Joshi

  • NA
  • 34
  • 0

mail sending

Jan 16 2010 4:29 AM

I have code like below for mail sending it runs successfully bt it goes to spam instead of inbox?can anybody give solution for this?
 
private
void SendMail()
{

try
{
MailMessage Email=new MailMessage();//Creating the Mail Message object.
Email.To=txtTo.Text;
//Storing the To value in the object reference.
Email.From=txtFrom.Text;
//Storing the From value in the object reference.
Email.Cc=txtCC.Text;
//Storing the CC value in the object reference.
Email.Bcc=txtBCC.Text;
//Storing the BCC value in the object reference.
Email.Subject=txtSubject.Text;
//Storing the Subject value in the object reference.
Email.Body=txtMessage.Text;
//Specifies the email body.
Email.Priority=
MailPriority.High;//Setting priority to the mail as high,low,or normal
Email.BodyFormat=
MailFormat.Text;//Formatting the mail as html or text.
//Checking whether the attachment is needed or not.
if(rbtnAttach.Checked)
{
Email.Attachments.Add(
new MailAttachment(FileBrowse.Value));//Adding attachment to the mail.
}
SmtpMail.SmtpServer.Insert(0,"127.0.0.1");//specifying the real SMTP Mail Server.
SmtpMail.Send(Email);//Sending the mail.
Reset();
//calling the reset method to erase all the data after sending the mail.
lblMessage.ForeColor=
Color.Navy;
lblMessage.Text=
"*Your email has been sent successfully-Thank You";//User information after submission.
}
//Catching Exception
catch(Exception exc)
{
Reset();
lblMessage.Text=
"Send error:"+exc.ToString();
lblMessage.ForeColor=
Color.Red;

}
}

Answers (1)