本文介绍了如何在asp.net中自动获取回复邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从mail2获取自动回复邮件。这是代码。
I need to get the automatic reply mail from mail2. here is the code.
string from = "[email protected]";
string to = "[email protected]";
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 = "[email protected]";
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)
{
}
但我收到来自[email protected]的回复自动回复,我需要回复来自[email protected]。帮助我如何编码...
but i am getting reply automatic response from [email protected] , i need to get reply from [email protected]. help me how to code...
推荐答案
string from = "[email protected]";
string to = "[email protected]";
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 = "[email protected]";
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中自动获取回复邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!