Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:31:24+00:00 2026-06-14T17:31:24+00:00

I have started using windows form for creating a small App in which user’s

  • 0

I have started using windows form for creating a small App in which user’s are able to send email from their gmail accounts, i’m able to send mails when user enters correct login credentials in my login form(FORM 1) but if he enters wrong credentials in login form(Form 1),it enters my Mail(form 2) and shows error so i want to check Gmail Login Credentials..Help me with the Code…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;

namespace first
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1 a = new Form1();
            this.Hide();
            a.ShowDialog();
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            client.Credentials = new NetworkCredential(Form3.tb.Text, Form3.tb1.Text);
            MailMessage msg = new MailMessage();
            msg.To.Add(new MailAddress(To.Text));
            msg.From = new MailAddress(From.Text);
            msg.Subject = Sub.Text;
            msg.Body = Body.Text;
            client.EnableSsl = true; //for security in gmail,https kind of
            client.Send(msg);
            try
            {
                MessageBox.Show("Mail sent successfully", "Praveen Mail");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Mail Sending Failed Due to" + ex.Message, "Praveen Mail");
            }

        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:31:26+00:00Added an answer on June 14, 2026 at 5:31 pm

    Google provides a .net api that should solve your problem.

    https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2

    ———EDIT——-

    Step 1: Sign up to use google api’s. It’s free and the process to do so is described in the link above.

    Step 2: Implement the code below. I borrowed it from the link above.

    using System;
    using System.Diagnostics;
    using DotNetOpenAuth.OAuth2;
    using Google.Apis.Authentication.OAuth2;
    using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
    using Google.Apis.Samples.Helper;
    using Google.Apis.Tasks.v1;
    using Google.Apis.Tasks.v1.Data;
    using Google.Apis.Util;
    
    namespace Google.Apis.Samples.TasksOAuth2
    {
        /// <summary>
        /// This sample demonstrates the simplest use case for an OAuth2 service. 
        /// The schema provided here can be applied to every request requiring   authentication.
        /// </summary>
        public class Program
        {
        public static void Main(string[] args)
        {
            // Display the header and initialize the sample.
            CommandLine.EnableExceptionHandling();
            CommandLine.DisplayGoogleSampleHeader("Tasks API");
    
            // Register the authenticator.
            var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
            provider.ClientIdentifier = "<client id>";
            provider.ClientSecret = "<client secret>";
            var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
    
            // Create the service.
            var service = new TasksService(auth);
            TaskLists results = service.Tasklists.List().Fetch();
            Console.WriteLine("Lists:");
            foreach (TaskList list in results.Items)
            {
                Console.WriteLine("- " + list.Title);
            }
            Console.ReadKey();
        }
    
        private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
        {
            // Get the auth URL:
            IAuthorizationState state = new AuthorizationState(new[] { TasksService.Scopes.Tasks.GetStringValue() });
            state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
            Uri authUri = arg.RequestUserAuthorization(state);
    
            // Request authorization from the user (by opening a browser window):
            Process.Start(authUri.ToString());
            Console.Write("  Authorization Code: ");
            string authCode = Console.ReadLine();
            Console.WriteLine();
    
            // Retrieve the access token by using the authorization code:
            return arg.ProcessUserAuthorization(authCode, state);
        }
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using https://github.com/omab/django-social-auth and been successfully able to login via twitter, google
I have started using jQuery and rails. I have made a simple form that
I have started prgramming a windows service. I have added a notify icon from
I have a windows form application which needs to be the TopMost. I've set
I have a Windows Form app that creates a window and monitors for entries
I have just started using WPF forms instead of Windows Forms forms. In a
I'm new to this site, and basically I have created a Windows Form using
I have three pages main page popup page started from main page using onclick
I have a thread started and I want the user to be able to
I have started using WSO2 Stratos live and started using WSO2 data services server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.