gpt4 book ai didi

C#通过网络浏览器自动登录gmail/hotmail

转载 作者:行者123 更新时间:2023-11-30 23:32:58 27 4
gpt4 key购买 nike

我正在尝试做类似 LassPass 的东西,但作为桌面应用程序。我使用 VS 2013、C# 和 Windows 窗体。

我有 gmail 或 outlook 的用户电子邮件和密码,我想单击桌面程序中的一个按钮以打开本地默认浏览器,即 Chrome/Firefox 以及适当的链接。我想在服务(gmail/outlook)中自动登录。我想问一下我是否必须使用适当的 API 或仅使用某种链接 ( https://mail.google.com/login= "userlogin",password="userpassword") 会很好。

我看到一个 gmail API,里面有如何发送邮件,但我找不到如何登录服务。

Gmail 或 Outlook API 函数中有哪些可以帮助我?

最佳答案

您正在寻找Selenium

一旦你设置好了,你可以做类似的事情

using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;

class Test
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://www.gmail.com/");
IWebElement query = driver.FindElement(By.Id("Email"));
query.SendKeys("my.email@gmail.com");
query = driver.FindElement(By.Id("next"));
query.Click();
// now you just have to do the same for the password page

driver.Quit();
}
}

您可能会发现这些链接有帮助:

关于C#通过网络浏览器自动登录gmail/hotmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34099979/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com