How to log Gmail in ASP .NET MVC 5 [closed]

。_饼干妹妹 提交于 2019-12-22 01:44:57

问题


When I log into my WebApplication i would like to be also automatically logged into Gmail. Exactly like I would go to gmail.com and typed my e-mail address and password myself.

It has to be done on client's side thus one must use Java Script. Let's make a premiss that we already know login and password:

 function LoginGmail(login, password) {

    }

Question: How to login to Gmail via Java Script?


回答1:


I could not get your question clearly but what I think is that you want to send an email to someone by C# code. Here is the code which you can use.

SmtpClient client = new SmtpClient();
            MailMessage msg = new MailMessage();                
            MailAddress to = new MailAddress("client email address");
            MailAddress from = new MailAddress("Your Email Address");
            msg.IsBodyHtml = true;
            msg.Subject = "Mail Title";
            msg.To.Add(to);
            msg.Body = "Your message";
            msg.From = from;
            client.Send(msg);

In web.config file under configuration section, you need to write the credential information of your mail account

    <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com" port="587" userName="your email address" password="your password" defaultCredentials="false" enableSsl="true" />
      </smtp>
    </mailSettings>
  </system.net>


来源:https://stackoverflow.com/questions/25650773/how-to-log-gmail-in-asp-net-mvc-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!