如何在asp.net中自动获取回复邮件 [英] how to get reply mail automatic in asp.net

查看:124
本文介绍了如何在asp.net中自动获取回复邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从mail2获取自动回复邮件。这是代码。



I need to get the automatic reply mail from mail2. here is the code.

string from = "noreplymail@gmail.com";
       string to = "mail2@gmail.com";
       string Password = "password123";
       int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
       string smtp = Convert.ToString(ConfigurationManager.AppSettings["smtp"]);
       string Subject = "Enquiry";
       string body = "Sender Name :" + txtname.Text + "\n" +
                    "Phone :" + txtphone.Text + "\n" +
                    "Email :" + txtemail.Text + "\n" +
                    "Address :" + txtaddress.Text + "\n"
                    + "Enquiry :" + txtenquiry.Text;
       string fromr = "mail2@gmail.com";
       string tor = txtemail.Text;
       string reply = "Enquiry feedback";
       string bbdy = "soon in touch";
       MailMessage Msg = new MailMessage(from, to, Subject, body);
       MailMessage replyMsg = new MailMessage(fromr, tor, reply, bbdy);
       //Smtp Host is the  name or Ip host of the computer used for sending mail
       SmtpClient smtpobj = new SmtpClient("smtp.gmail.com", 587);
       smtpobj.Host = "smtp.gmail.com";
       smtpobj.Port = 587;
       smtpobj.EnableSsl = true;
       smtpobj.UseDefaultCredentials = false;
       smtpobj.Credentials = new System.Net.NetworkCredential(from, Password);

       try
       {
           smtpobj.Send(Msg);
           smtpobj.Send(replyMsg);

       }
       catch (Exception ex)
       {

       }







但我收到来自noreplymail@gmail.com的回复自动回复,我需要回复来自mail2@gmail.com。帮助我如何编码...




but i am getting reply automatic response from noreplymail@gmail.com , i need to get reply from mail2@gmail.com. help me how to code...

推荐答案

我对你的理解有多少问题是你得到了错误来源的回复,因为你想从上面指定的同一封邮件回复



How much i understand you question is you are getting reply from wrong source as you want reply from the same email you specified above

string from = "noreplymail@gmail.com";
string to = "mail2@gmail.com";
string Password = "password123";
int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
string smtp = Convert.ToString(ConfigurationManager.AppSettings["smtp"]);
string Subject = "Enquiry";
string body = "Sender Name :" + txtname.Text + "\n" +
"Phone :" + txtphone.Text + "\n" +
"Email :" + txtemail.Text + "\n" +
"Address :" + txtaddress.Text + "\n"
+ "Enquiry :" + txtenquiry.Text;

//You dont need to provide from mail again as you have specified above
//string fromr = "mail2@gmail.com";

string tor = txtemail.Text;

string reply = "Enquiry feedback";
string bbdy = "soon in touch";
MailMessage Msg = new MailMessage(from, to, Subject, body);

//change 'fromr' to 'to'
MailMessage replyMsg = new MailMessage(to, tor, reply, bbdy);


这篇关于如何在asp.net中自动获取回复邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆