问题描述
我为我的网站创建了一个联系页面,在该联系页面中我有姓名字段,电子邮件字段,主题字段和消息字段以及提交表单...我发送了我的电子邮件ID的所有详细信息。
我的问题是,要将所有信息发送到我的电子邮件ID,我需要在地址中提及我的邮件ID ...我很困惑并从电子邮件地址
如果您有任何建议请帮助。
代码是:
protected void btnSend_Click(object sender,EventArgs e)
{
MailMessage mm = new MailMessage(sender @ gmail .com,[email protected]);
mm.Subject = txtSubject.Text;
mm.Body =姓名:+ txtName.Text +
电子邮件:+ txtEmail.Text +
+ txtBody.Text;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host =smtp.gmail.com;
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName [email protected];
NetworkCred.Password =xxxxx;
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
lblMessage.Text =Email Sent SucessFully。;
}
I have created a contact page for my website and in that contact page i have Name field , Email field , Subject Field , and Message Field and on submission of form ... i sent all the details on my email id .
My question is that to send all the information to my email id do i need to mention my mail id in to and from address both ... i am confused with to and from email address
if u have any suggestions please help.
code is :
protected void btnSend_Click(object sender, EventArgs e)
{
MailMessage mm = new MailMessage("[email protected]", "[email protected]");
mm.Subject = txtSubject.Text;
mm.Body = "Name: " + txtName.Text + "
Email: " + txtEmail.Text + "
" + txtBody.Text;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "[email protected]";
NetworkCred.Password = "xxxxx";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
lblMessage.Text = "Email Sent SucessFully.";
}
推荐答案
这篇关于当我必须将所有信息发送到我的电子邮件地址时,应该从联系页面的电子邮件地址中使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!