Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello
I can not sign out from Gmail.
JavaScript
webBrowser_1.Document.GetElementById("sign out").InvokeMember("click");
Posted
Updated 22-Mar-15 7:14am
v2
Comments
Mehdi Gholam 22-Mar-15 3:05am    
SmtpClient has nothing to do with a web browser.
aazam rafiee zade 22-Mar-15 12:07pm    
I connected to Gmail with:
private void SetValues(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
if (webBrowser_1.Document.GetElementById("Email").InnerText == null)
{
webBrowser_1.Document.GetElementById("Email").InnerText = My Gmail Address;
webBrowser_1.Document.GetElementById("Password").InnerText = My Gmail password;
webBrowser_1.Document.GetElementById("signIn").InvokeMember("click");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void button_Connect_Click(object sender, EventArgs e)
{
string url = "https://mail.google.com/mail/u/0/h/10sywa7buyj4c/";
try
{
this.webBrowser_1.Navigate(url);
this.webBrowser_1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SetValues);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
But I cannot sign out.

You only need to navigate to this url:
https://accounts.google.com/logout[^]
C#
string url = "https://accounts.google.com/logout";
this.webBrowser_1.Navigate(url);
 
Share this answer
 
Comments
aazam rafiee zade 22-Mar-15 16:24pm    
I run this code, but log in occur again.
private void button_Disconnect_Click(object sender, EventArgs e)
{
try
{
string url = "https://accounts.google.com/logout";
//string url = "https://mail.google.com/mail/logout?hl=en";
this.webBrowser_1.Navigate(url);
label_disconnection.Visible = true;
label_connecttogmail.Visible = false;
textBox_From.Text = "";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I used just this code. Now I can disconnect from Gmail.
private void button_Disconnect_Click(object sender, EventArgs e)
{
try
{
webBrowser_1.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(SetValues);
label_disconnection.Visible = true;
label_connecttogmail.Visible = false;
textBox_From.Text = "";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900