forum.venkateswarlu.net
      Register      Login
How can i access Gmail authentication using Asp.net

2 replies to this topic

Kalyan Suman #1
Member
150 Points
Posted on 04 Nov 2014 06:03 PM IST

i want to implement gmail functionality to my site  it is easy in mvc

but i want to implement in aspx pages please send me link regarding this task

Thanks in Advance

 
ASP.NET     798 views     Reply to this topic
Cherukuri Venkateswarlu #2
Member
140 Points
Replied on 05 Nov 2014 05:43 AM IST You can use the below code to send Email using gmail account.

protected void SendEmail(object sender, EventArgs e)
{
    using (MailMessage mm = new MailMessage(txtEmail.Text, txtTo.Text))
    {
        mm.Subject = txtSubject.Text;
        mm.Body = txtBody.Text;
        if (fuAttachment.HasFile)
        {
            string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
            mm.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
        }
        mm.IsBodyHtml = false;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.EnableSsl = true;
        NetworkCredential NetworkCred = new NetworkCredential(txtEmail.Text, txtPassword.Text);
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.Send(mm);
        ClientScript.RegisterStartupScript(GetType(), "alert""alert('Email sent.');"true);
    }
}
 
Reply to this topic
Kalyan Suman #3
Member
150 Points
Replied on 05 Nov 2014 01:58 PM IST

hi venketesh thanks for ur reply

 my requirement is  i want to access through gmail account to my web page suppose i will put one button eg:-- ConnectGmail when i click my button gmail login page is appear then after login the credentials i want to return back to my page , now u got it my task venkat

 
Reply to this topic