我使用IWebBrowse2  来实现的
在IWebBrowse2   的 OnDocumentCompleteExplorer1中执行了两个函数.
{
    CComQIPtr< IWebBrowser2 > spBrowser = pDisp;
CComPtr < IDispatch > spDispDoc;
spBrowser->get_Document( &spDispDoc );
CComQIPtr< IHTMLDocument2 > spDocument2 = spDispDoc; 
CString   strUrl,strTemp;    //登入邮件
         strUrl    = this->m_internetexplorer .GetLocationURL ();//得到当前网页的URL   if (strUrl=="https://login.yahoo.co.jp/config/login?")
{
             
  Loginemail(spDocument2);
return;
}
        //上面都很正常 //进入写邮件 if (strUrl=="http://www.yahoo.co.jp/")
{
                //执行下面这个函数有问题 页面可以自动转到 http://www.yahoo.co.jp/ 当中去
Linkemail_1(spDocument2); return;

}
}//下面是函数定义bool   Linkemail_1(IHTMLDocument2*   pHTMLDoc2) 
{

IHTMLElementCollection*   pElementCol=NULL; 
HRESULT hr;
USES_CONVERSION;
CComQIPtr< IHTMLElementCollection > spElementCollection;
CComPtr<IHTMLElement> pElement;
hr = pHTMLDoc2->get_forms( &spElementCollection ); //取得表单集合
if ( FAILED( hr ) )
{
AfxMessageBox("获取表单的集合 IHTMLElementCollection 错误");
return  false;
} long nFormCount=0; //取得表单数目
hr = spElementCollection->get_length( &nFormCount );
if ( FAILED( hr ) )
{
AfxMessageBox("获取表单数目错误");
return  false;
} for(long i=0; i<nFormCount; i++)
{
IDispatch *pDispatch = NULL; //取得第 i 项表单
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDispatch );     if ( FAILED( hr ) ) continue;
    
        IHTMLElement*   pElement=NULL;   
        hr = pDispatch->QueryInterface(IID_IHTMLElement,(void**)&pElement);
    if ( FAILED( hr ) )
{
AfxMessageBox("获取表单数目错误");
return  false;
}
  
    IHTMLInputTextElement*   pInputElement=NULL;   
        if   ( pDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)==0)   

                  //这里怎么也获取不到信息 页面上有很多 IHTMLInputTextElement类型的.我直接打开下栽的页面看过
  AfxMessageBox("lssrc");
 
  
}
  }   
    
 return true;
}