Link to home
Start Free TrialLog in
Avatar of jmulder
jmulder

asked on

Accessing Webmail directly

Is there any code which shows how to access Webmail (eg; hotmail) inbox directly.

Maybe using fpiette´s internet suite.

I want to check my Webmail without opening it using Explorer.

Avatar of cobramania
cobramania

As long as you know the smtp and pop3 server and you know the port the used, you can use SMTP component to access it.
And for hotmail i don't think you could access it coz it's for trial only if i'm not mistaken

And code for accessing web mail is same with accessing standard mailbox.

Hope this helps
It is possible using TNMHTTP or F. Piettes equivalent component. But where do you want to store the response? Sending a request always returns an HTML page, just like you will get in a web browser.
Avatar of jmulder

ASKER

I want to access Webmail such as Hotmail without (i.e. not POP3 accounts) Sorry.

Re: Epsylon´s comments

I want to open my browser at the Hotmail inbox directly. Not the login screen.

I eventually want to download the inbox page and parse this to see what mail I´ve got without downloading it.

jmulder
You have to automate the login sequence. How this has to be done depends on which webmail system you use.

If you look at the HTML-source of the login page your'll see a <form ...> tag somewhere like this:

<form name="form1" action="/cgi-bin/login.dll" >
  <input type="text" name="name">
  <br>
  <input type="password" name="password">
  <br>
  <input type="submit" name="Submit" value="Submit">
</form>


When a user clicks on 'submit' the browser 'post' the name and password to the webserver by calling the login.dll. The result will be sent back to your browser.

You can simulate this action with components like TNMHTTP (note: TNMHTTP does not support frames and some other things).
If you have Delphi 5, you can easily use TWebBrowser too.
Avatar of jmulder

ASKER

Dear Epsylon

This looks like what I want. I don´t know if I have TNMHTTP. I will look. I use D3.

I figured I could use one of fpiette´s internet components to send CGI data direct...I just don´t know how and then what to do with the response.

Jmulder
If you use the THttpCli component from F.Piette the try the HttpTst demo.

To test it I took an ASP example that uses the post method, so you can try the HTTP demo right now:

http://www.learnasp.com/learn/formtextarea.asp


In the Http demo fill in the URL field like this:

http://www.learnasp.com/learn/test/FormTextAreaRespond.asp

And the data field like this:

shippingComments=This%20is%20a%20test!

Then click the Post button and see what happens.....


When you have to post multiple data fields then separate them with a '&':

username=myname&password=mypassword


Don't forget to use the https protocol when necessary.
Avatar of jmulder

ASKER

Dear Epsylon
I will try this asap. I don´t have a home connection. I have to bring floppy to CyberCafe ... hence the delays from my end.
To use the HTTPS do I just have to write  HTTPS instead of HTTP or is there something else to do. Also what do I put in Proxy field?
HTTPS means that you open a secure connection. It's often used when you send passwords etc. And yes, use https instead of http.


Example:

https://www.somedomain.com/cgi-bin/login.dll


The proxy field is needed when you are connected to the Internet via a proxyserver, which is most likely not the case. Just leave it blank.
Avatar of jmulder

ASKER

Epsylon

I tried HTTPTST...(sorry for the long comment)

I use netaddress for mail, their login form looks as follows...

             <form name="loginform" onSubmit="SubmitLogin(); return true;" action="/tpl/Door/LoginPost" method="POST">
             <input type="hidden" name="LoginState" value="2">
             <input type="hidden" name="SuccessfulLogin" value="/tpl">
             <input type="hidden" name="NewServerName" value="www.netaddress.com">
             <input type="hidden" name="JavaScript" value="None">
             <input type="hidden" name="DomainID" value="4">
             <input type="hidden" name="NA31site" value="classic.netaddress.com">
             <input type="hidden" name="NA31port" value="80">

             <input type="text" size="16" name="UserID">
             <input type="password" size="16" name="passwd">
             <input type="submit" value="Login">
             <input type="checkbox" name="Expire_Cache" value="1">
             <input type="checkbox" name="Use_Cookie" value="1">

The SubmitLogin() function just sets the correct JavaScript version.

I have used various combinations of data including a complete line...

SuccessfulLogin=/tpl&NewServerName=www.netaddress.com&JavaScript=JScript1.0&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=jtmulder&passwd=mypassword&Expire_Cache=1&Use_Cookie=1

and always get an error which says BadDomain back from netaddress. I am asumming that the data has to appear in the same order as appears in the form.

jmulder

Are the hidden parameters of the formalways the same? If not then things will become complicated.

But check this first:

I added the LoginState parameter and replaced a '/' with %47 (=url encoded):

LoginState=2&SuccessfulLogin=%47tpl&NewServerName=www.netaddress.com&JavaScript=JScript1.0&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=jtmulder&passwd=mypassword&Expire_Cache=1&Use_Cookie=1


and the order *should* not be important. Don't forget to supply the entire url.
Avatar of jmulder

ASKER

Epsylon,

Oops, I forgot the LoginState.

I tried all this but I always get the same. As far as I see the login screen is always the same. I compared it with one I saved last year and there is no difference in code.

What makes me suspicious is that I get the same message even when I supply the wrong password. When I do this from the login screen I a message BadPass but with HTTPTST I still get BadDomain.

If you have HTTPTST you can see what I mean.

jmulder
I entered the following:

URL:

http://www.netaddress.com/tpl/Door/LoginPost

Data:

LoginState=2&SuccessfulLogin=%47tpl&NewServerName=www.netaddress.com&JavaScript=JScript1.0&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=jtmulder&passwd=mypassword&Expire_Cache=1&Use_Cookie=1


The I pressed the post button and got the following response:

<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.netaddress.com/tpl/Door/Terminated?Reason=BadPasswd">

</html>



Don't know what happens when I supply the right password.....
Avatar of jmulder

ASKER

Nearly there...

Oops again...I was using "Get"
This time I got...

<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=Gtpl/Door/506KTHQKE/Welcome">
</head>
</html>
This is what appears in the address bar when you log in using the browser.

Now I need to get this to open my browser. You can´t just ShellExecute this (http://www.netaddress.com/tpl/Door/506KTHQKE/Welcome) because the server replies termination...reason: Intrusion.

Avatar of jmulder

ASKER

Epsylon

That´s what I thought but this gives me an error - 13 which I think just means bad URL.

So I tried tpl instead because when you log in to Netaddress this is the URL you always end up with, not Gtpl.

I have have opened up a Netaddress account just to try this...

Username: expertsexchange
Password: expertsexchange

You´ll see what I mean.

PS: You already deserve the points for this even if we don´t get past this point but please don´t give up because I think we are close.
Avatar of jmulder

ASKER

I got your last message saying a lot goes on behind the scenes after login but this message has dissappeared?!

There is a program that does exactly what I want to do...it´s called AnyMail and is at:

http://www.tntsb.com/anymail/

I was reading their feedback (which I can´t find any more so I can´t quote exactly) and they had problems with Netaddress which had something to do with the way the pages are cached.

Don´t know what they meant but they sorted it.

jmulder

Still no luck here.....   :o(
Avatar of jmulder

ASKER

When Netaddress sends the lines:

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=...

it sends it to the browser which it thinks sent the CGI data and this refreshes the same browser to new page does it not.

It may be possible to automate this process by having a local HTML document (login.html) which sends the login data automatically instead of waiting for user to press the LOGIN button.

Can forms be activated automatically?
Just a thought...


Well... it's possible to use TWebBrowser in you Delphi app but since you use Delphi 3 it's very difficult for me to get the job done. Another problem could be that not all computers have this object installed.
Avatar of jmulder

ASKER

What about just using Explorer directly. i.e have an HTML doc which activates the form automatically and just shell executing it to fire up explorer...I know it´s not exactly what I want but...

Send your next comment as an answer and I will give you the points. Answers can be graded.

You deserve it. If you find a way after this then please send it to me at jmulder@hotmail.com

ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmulder

ASKER

Yes please. It will have to do for now until we find a direct Delphi solution.

Ok, here it is:


----------- Login.htm -------------

<html>
<head>
<TITLE>Login</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>


<SCRIPT language="Javascript">
<!--
function SubmitLogin()
{
   var temp;
   document.loginform.SuccessfulLogin.value="/tpl";
   document.loginform.NewServerName.value="www.netaddress.com";
   document.loginform.JavaScript.value="JScript1.0";

  if (navigator.userAgent.indexOf("Mozilla/5.") != -1)
  {
   document.loginform.JavaScript.value="JavaScript1.2";
  }
  else if (navigator.userAgent.indexOf("Mozilla/4.") != -1)
  {
   document.loginform.JavaScript.value="JavaScript1.2";
  }
  else if (navigator.userAgent.indexOf("Mozilla/3.0") != -1)
  {
   document.loginform.JavaScript.value="JavaScript1.1";
  }
  else if (navigator.userAgent.indexOf("MSIE") != -1)
  {
   document.loginform.JavaScript.value="JScript1.0";
  }
  else if (navigator.userAgent.indexOf("Mozilla/2.0") != -1)
  {
   document.loginform.JavaScript.value="JavaScript1.0";
  }
}

function AutoLogin()
{
  SubmitLogin();
  loginform.submit();
}
//-->
</SCRIPT>

<body onLoad="AutoLogin()">
<form name="loginform" action="http://www.netaddress.com/tpl/Door/LoginPost" method="POST">
    <input type="hidden" name="LoginState" value="2">
    <input type="hidden" name="SuccessfulLogin" value="/tpl">
    <input type="hidden" name="NewServerName" value="www.netaddress.com">
    <input type="hidden" name="JavaScript" value="None">
    <input type="hidden" name="DomainID" value="4">
    <input type="hidden" name="NA31site" value="classic.netaddress.com">
    <input type="hidden" name="NA31port" value="80">
    <input type="hidden" name="UserID" value="expertsexchange">
    <input type="hidden" name="passwd" vlue value="expertsexchange">
</form>
</body>
</html>

-------------------------------

Start it from Delphi with:


uses ShellAPI;

ShellExecute(handle, 'open', 'Login.htm', '', '', SW_SHOWNORMAL);