[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Auto Login to a asp webpage in my delphil app.

Posted on 2006-11-12
3
Medium Priority
?
360 Views
Last Modified: 2010-04-05
Hi all i have a project i am working on that logs into email account and checks email. I am looking for a solution the can login to a asp webpage it has a form username and password.. I am useing a Twebbrowser to load the url. I want to laod my username and password in the asp form in my Twebbrowser and auto login. See link below.
http://mail.grantfullen.com/
username: test@grantfullen.com
pass: test
0
Comment
Question by:Grant Fullen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 17925918
there are 3 login examples here: http://www.ciuly.com/delphi/indy/index.html
the basic idea is the same for all demos so you should be able to adapt the one that suits your purpose better to your site.
of course this is using indy and not twebbrowser.

if you do want to use twebbrowser for this (though I can't see why), you will do something like:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls, mshtml;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
    procedure WebBrowser1DocumentComplete(Sender: TObject;
      const pDisp: IDispatch; var URL: OleVariant);
  private
    { Private declarations }
  loginForm: IHTMLFormElement;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  WebBrowser1.Navigate('http://mail.grantfullen.com/');
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  htmlDoc: IHTMLDocument2;
  allForms: IHTMLElementCollection;
  field: IHTMLElement;
  inputField: IHTMLInputElement;
  a,u :olevariant;
begin
  if url<>'http://mail.grantfullen.com/' then
    exit;
  htmlDoc := WebBrowser1.Document as IHTMLDocument2;
  allForms := htmlDoc.Forms;
  loginForm := allForms.Item('Login','') as IHTMLFormElement;
  field := loginForm.Item('txtUserName','') as IHTMLElement;
  if assigned(field) then
  begin
    inputField := field as IHTMLInputElement;
    inputField.value := 'test@grantfullen.com';
  end;
  field := loginForm.Item('txtPassword','') as IHTMLElement;
  if assigned(field) then
  begin
    inputField := field as IHTMLInputElement;
    inputField.value := 'test';
  end;
  a:=WebBrowser1.OleObject.document.all.tags('a').item(0);
  u:=a.href;
  WebBrowser1.Navigate2(u);
end;

end.





dfm follows:


object Form1: TForm1
  Left = 192
  Top = 125
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object WebBrowser1: TWebBrowser
    Left = 0
    Top = 48
    Width = 688
    Height = 398
    TabOrder = 0
    OnDocumentComplete = WebBrowser1DocumentComplete
    ControlData = {
      4C0000001B470000222900000000000000000000000000000000000000000000
      000000004C000000000000000000000001000000E0D057007335CF11AE690800
      2B2E126208000000000000004C0000000114020000000000C000000000000046
      8000000000000000000000000000000000000000000000000000000000000000
      00000000000000000100000000000000000000000000000000000000}
  end
end


for more info about twebbrowser and ole automation, see http://www.cryer.co.uk/brian/delphi/twebbrowser/twebbrowser_oleobject.htm
you might also consider moving to TEmbeddedWB: http://www.bsalsa.com/product.html
0
 

Author Comment

by:Grant Fullen
ID: 17926193
I like the PersistentConnection example but not working well . Invaled Date Code.. Bit it seems simlar to what i will need.
0
 
LVL 28

Expert Comment

by:2266180
ID: 17926575
so ... did you get it to work or still need help?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question