如何在asp.net中为所有网页提供邮件ID [英] How to make the mail id available to all web page in asp.net

查看:72
本文介绍了如何在asp.net中为所有网页提供邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用注册表单进行Web应用程序。

*最初,如果是新用户,则用户应输入用户名和邮件ID等的注册详细信息。注册后,用户将被重定向到登录页面。

*如果用户是普通用户,则用户将直接进入登录页面。

*在接下来的页面中,我已经包含了一些电子邮件概念,用户可以通过仅提供收件人邮件ID来询问查询

*用户无需提供邮件ID而是必须从注册详细信息中自动从数据库中检索。

*简而言之,我想要类似于facebook的概念,其中用户的信息在整个页面中可用,并且我们不是每次都输入用户名。

*我只能提供可用的用户名,因为它可以从登录页面检索,但我无法检索邮件ID,因为它存储在数据库中。

*这个是我的代码。我已经给了我的邮件ID,而不是从注册表中检索。

*我需要邮件ID在注册邮件ID文本框中的来自地址中可用



I am currently doing web application with has a registration form.
*Initially, if its the new user, the user is supposed to enter the registration details with username and mail id etc. And upon registration the user will be redirected to login page.
*If the user is regular user, the user will directly go to login page.
*On successive pages I have included some email concept where the user can ask queries by giving only the recipient mail id
*The user need not give his mail id instead it must be automatically retrieved from database from the registration details.
*In short I want the concept similar to facebook where the user's information is available throughout the pages and where we are not entering username each and every time.
*I can make only the username available because it can be retrieved from login page but I cant make the mail id to retrieve because it is stored in database.
*This is my code.I have given my mail id instead of retrieving from the registration table.
*I need the mail id to be available in this "from address"from the registered mail id textbox

if (Page.IsValid)
              {
                 
                  MailMessage mailmessage = new MailMessage();
  //have given  from mail id
                  mailmessage.From = new MailAddress("####@gmail.com");
                  mailmessage.To.Add(new System.Net.Mail.MailAddress(Textemail.Text));
                  mailmessage.Subject = TextSub.Text;
                  mailmessage.Body = "<b>Query from : </b>" + Textname.Text + "<br/>" +
                      "<b>Sender Details : </b>" + Textemail.Text+ "<br/>" +
                      "<b>Queries Asked : </b>" + Textcomment.Text + "<br/>";
                  
                  mailmessage.IsBodyHtml = true;
                 
                  SmtpClient smtpclient = new SmtpClient("smtp.gmail.com", 587);
                  smtpclient.EnableSsl = true;
                  smtpclient.Credentials = new System.Net.NetworkCredential("anudroidapp@gmail.com", "anudroiddeve2094");
                  smtpclient.Send(mailmessage);
                  SuccessLabel.Text = "Your Query has been successfully sent to Appropriate mail id";
                  //after sending email ie after clicking the send button all the controls wl b dispabled so tat inoru vati click pana mudayadu user!!!
                  Textname.Enabled = false;
                  Textemail.Enabled = false;
                  TextSub.Enabled = false;
                  Textcomment.Enabled = false;
                  SendMsg.Enabled = false;

     }







我是.Net的新手。请帮忙。在此先感谢




I am new to .Net.Please help.Thanks in advance

推荐答案

这是一个基本项目,您将为用户提供基本工具,例如,





  • 注册您的服务。
  • 必须登录才能使用您的服务。
  • 通过您的服务发送电子邮件他自己的帐户。
This is a basic project where you will provide the user with basic tools like,


  • Registering to your service.
  • Must be logged in to use your service.
  • Send emails through your service from his own account.
var loggedIn = WebSecurity.IsAuthenticated; // returns bool





你也可以注册一个新用户,只要问他这些细节,





  • 用户名
  • 密码(无论是为您服务还是为两者兼有)
  • WebSecurity.CreateAccount(username, password, false);





    在这里学习, http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.createaccount(v = vs.111)的.aspx [<一个href =http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.createaccount(v=vs.111).aspx\"target =_ blanktitle =New Window> ^ ]



    保存用户详细信息



    您可以使用数据库存储任何信息关于用户。 SQL Server不会阻止添加任何内容,它将存储用户名,密码或您要为用户存储的任何内容。



    完成后,您始终可以通过数据库查询并选择要获取的列或数据。之后,您可以按该数据填写MailMessage类。您不需要始终将包含数据的字符串插入到类中以初始化它们,您也可以将动态数据传递给它。



    与使用C#.NET代码发送电子邮件相比,在ASP.NET中发送电子邮件很容易。您可以使用ASP.NET方式执行此操作。这是我写的一篇文章,轻松使用ASP.NET助手发送电子邮件 [ ^ 。我希望它可以帮到你。



    Learn it here, http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.createaccount(v=vs.111).aspx[^]

    Saving user details

    You can use the database to store any information about the user. SQL Server won't prevent anything from being added, it will store username, password or anything that you want to store for the user.

    Once done, you can always query through the database and select the columns or data that you want to fetch. After that, you can fill in the MailMessage class by that data. You don't require to always insert the strings containing the data into the classes to initialize them, you can pass dynamic data to it too.

    Sending an email in ASP.NET is easy as compared to sending emails in C# .NET code. You can use the ASP.NET way of doing it. Here is an article that I wrote, Sending Emails Easily Using ASP.NET Helpers[^]. I hope it might help you out.


    这篇关于如何在asp.net中为所有网页提供邮件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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