当我必须将所有信息发送到我的电子邮件地址时,应该从联系页面的电子邮件地址中使用什么? [英] What Should Use In From Email Address In Contact Page When I Have To Send All The Information To My Email Address ?

查看:162
本文介绍了当我必须将所有信息发送到我的电子邮件地址时,应该从联系页面的电子邮件地址中使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的网站创建了一个联系页面,在该联系页面中我有姓名字段,电子邮件字段,主题字段和消息字段以及提交表单...我发送了我的电子邮件ID的所有详细信息。



我的问题是,要将所有信息发送到我的电子邮件ID,我需要在地址中提及我的邮件ID ...我很困惑并从电子邮件地址



如果您有任何建议请帮助。



代码是:



protected void btnSend_Click(object sender,EventArgs e)

{

MailMessage mm = new MailMessage(sender @ gmail .com,receiver@gmail.com);

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 =sender@gmail.com;

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("sender@gmail.com", "receiver@gmail.com");
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 = "sender@gmail.com";
NetworkCred.Password = "xxxxx";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
lblMessage.Text = "Email Sent SucessFully.";
}

推荐答案

字段是收件人,收件人,而字段是发件人,发送电子邮件。 SMTP服务器或客户端将使用这些参数生成GUI,以便客户端读取发送电子邮件的人或发送电子邮件的人



如果您要向自己发送电子邮件,可以使用自己的电子邮件地址填写。 SMTP服务器不会抱怨两者都是一样的。如果您要向其他(或其他)电子邮件地址发送电子邮件,请将其添加到收件人字段,并将其保留为您拥有的电子邮件地址。



这完全取决于你的需要。
To field is for the recipient, the one who receives it whereas From field is for sender, the one sends the email. SMTP servers or clients would use these parameters to generate a GUI for the client to read who sent the email or who was sent the email.

In cases where you are going to send an email to yourself, you can fill in both with your own email address. SMTP servers won't complain about both being the same. If you want to send an email to additional (or some other) email address, add that to "To" field and leave yours as the one you own.

It totally depends on your need.


这篇关于当我必须将所有信息发送到我的电子邮件地址时,应该从联系页面的电子邮件地址中使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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