0
protected void btnSubmit_Click(object sender, EventArgs e)
{
    MailMessage msg = new MailMessage();
    msg.From = new MailAddress(txtlogfrom.Text);
    msg.To.Add(txtTo.Text);
    msg.Subject = txtSubject.Text;
    msg.Body = txtBody.Text;

    using (SmtpClient client = new SmtpClient())
    {
        client.EnableSsl = true;
        client.UseDefaultCredentials = false;
        client.Credentials = new NetworkCredential(txtlogfrom.Text, password);
        client.Host = "smtp.gmail.com";
        client.Port = 587;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.Send(msg);
    }
}

The Above Code is working when we give User Name and Password

But I need to send Auto Response mail to Sender, When He Send mail to Me.

Help Me to find the Solution

Thanks in Advance

Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
Selva
  • 546
  • 5
  • 12
  • 34
  • "When user receives email" could be classed as many things, is it when they physically open the email? Is it when the email just gets delivered into their inbox? Is it when the SMTP server "believes" it's successfully sent the email? – Arran Feb 04 '14 at 10:39

1 Answers1

-1

if the mailbox you want to monitor is entirely under your control. i.e. you have the credentials for it then you have a couple of options.

  1. Get a pop3 client and poll periodically e.g http://sourceforge.net/projects/hpop/
  2. Find an email service that will send you notifications when email is received. Such as MailGun
Ian1971
  • 3,666
  • 7
  • 33
  • 61