C#实现163邮箱的自动登录时遇到了问题,请高人赐教啊!
private void button1_Click(object sender, EventArgs e)
{
try
{
SHDocVw.InternetExplorer IE = new InternetExplorer();
IE.Visible = true;
string URL = "http://mail.
object nullArg = null;
IE.Navigate(URL, ref nullArg, ref nullArg, ref nullArg, ref nullArg);
System.Threading.Thread.Sleep(1000);
//得到IE的文档对象模型
mshtml.IHTMLDocument2 DOM = (mshtml.IHTMLDocument2)IE.Document;
//声明用户名
mshtml.IHTMLInputTextElement txtUserName = (mshtml.IHTMLInputTextElement)DOM.all.item("username", null);
txtUserName.value = "weijiezhang";
//声明密码
mshtml.IHTMLInputTextElement txtPwd = (mshtml.IHTMLInputTextElement)DOM.all.item("Password", null);
txtPwd.value = "wj310791";
//声明登录
mshtml.HTMLInputButtonElement btnLogin = (mshtml.HTMLInputButtonElement)DOM.all.item("null",0);
System.Threading.Thread.Sleep(1000);
btnLogin.click();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
其中
//声明登录
mshtml.HTMLInputButtonElement btnLogin = (mshtml.HTMLInputButtonElement)DOM.all.item("null",0);
System.Threading.Thread.Sleep(1000);
btnLogin.click();
,在btnlogin.click()处出现异常,“没有实例化对象”,请问该如何解决?