home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD9549922000.psc / ModData.bas < prev   
Encoding:
BASIC Source File  |  2000-09-03  |  4.9 KB  |  71 lines

  1. Attribute VB_Name = "Module"
  2. ''''''''''''''''''''''''''''' Hotmail Check Message ''''''''''''''''''''''''''''
  3. '                                                                              '
  4. '    This code uses the http/1.1 protocol to connect to the hotmail server     '
  5. '    and retrieve the mail box (note: when i use the term mailbox 'data'       '
  6. '    I am actually referring to the SOURCE CODE of the mailbox, which of       '
  7. '    course is sent in html format). This program does not use any special     '
  8. '    mail features, nor does it implement POP mail, it simply uses http        '
  9. '    commands to get the mailbox. Because it is so confusing, I tried the      '
  10. '    best i could to comment anywhere that there may be confusion, but         '
  11. '    if you are not familiar with socket programming or the http protocol,     '
  12. '    you will most likely have a difficult time understanding it.              '
  13. '    And although the only piece of data you see as a result of this program   '
  14. '    is how many new messages you have, once you understand how the program    '
  15. '    works, retrieving any other information about your hotmail account is     '
  16. '    a piece of cake. If you have any questions or comments, you can contact   '
  17. '    me at:  nmjblue@hotmail.com                                               '
  18. '                                                                              '
  19. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  20.  
  21. Public StrLogin As String, StrPass As String ' holds login and password
  22. Public NewHost As String, NewUrl As String ' new server and url after redirection (see below)
  23. Public BatchNumber As Integer ' holds the current batch number we need to send
  24. Public Cookies(6) As String ' stores cookies received, required for receiving mailbox (contains encrypted information read by server)
  25. Public CurrentCookie As Integer ' stores current cookie number, as there are numerous different ones
  26. Public MailData As String ' once we begin to receive data about mailbox, this is the string that stores it so we can retrieve the information
  27. Public ReadBox As Boolean, BoxBatch As Integer ' boolean for whether or not we are receiving the mailbox data, and batch number of the data we are receiving
  28.  
  29. ' Socket Values
  30. Public Const AF_INET = 2
  31. Public Const SOCK_STREAM = 1
  32. Public Const IPPROTO_IP = 0
  33. Public Const SOCKET_CONNECT = 2
  34. Public Const SOCKET_CANCEL = 5
  35. Public Const SOCKET_FLUSH = 6
  36. Public Const SOCKET_DISCONNECT = 7
  37.  
  38. Public Function MakeString(Connection As Integer) As String
  39. Dim strdata As String ' for temporary storage of data to send
  40. Dim feed As String
  41. feed = (Chr(13) & Chr(10)) ' carriage return & linefeed
  42.  
  43. Select Case Connection
  44. Case 0 'first batch of data sent, contains login information
  45.     Dim content As String
  46.     content$ = "login=" & StrLogin$ & "&domain=hotmail.com&passwd=" & StrPass$ & "&enter=Sign+in&sec=no&curmbox=ACTIVE&js=yes&_lang=&beta=&ishotmail=1&id=2&ct=963865176"
  47.     strdata = "POST /cgi-bin/dologin HTTP/1.1" & feed & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*" & feed
  48.     strdata = strdata & "Accept -Language: en -us" & feed & "Content-Type: application/x-www-form-urlencoded" & feed
  49.     strdata = strdata & "Accept -Encoding: gzip , deflate" & feed & "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" & feed
  50.     strdata = strdata & "Host: lc5.law5.hotmail.passport.com" & feed
  51.     strdata = strdata & "Content-Length: " & Len(content$) & feed & "Connection: Keep -Alive" & feed & feed
  52.     strdata = strdata & content$ & feed & feed
  53.     MakeString = strdata
  54. Case 1 'we get relocated to a new hotmail server (NewHost) containing the mailbox. here we request a new page, because contained in the url of the page (NewUrl) is our encrypted login and password
  55.     strdata = "GET /" & NewUrl$ & " HTTP/1.1" & feed
  56.     strdata = strdata & "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" & feed
  57.     strdata = strdata & "Host: " & NewHost$ & feed
  58.     strdata = strdata & "Cookie: MC1=V=2&GUID=B8E9C518070C49B18A9884F543033C33; mh=ENCA; MSPDom=; MSPAuth=; MSPProf=; MSPVis=; LO=; HMSC0899=; HMP1=1; HMSC0899="
  59.     strdata = strdata & feed & feed
  60.      '& feed
  61.     MakeString = strdata
  62. Case 2 'finally, we request the mailbox on the new server, by sending the cookies we received with all the encrypted information needed
  63.     strdata = "GET " & NewUrl$ & " HTTP/1.1" & feed
  64.     strdata = strdata & "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" & feed
  65.     strdata = strdata & "Host: " & NewHost$ & feed
  66.     strdata = strdata & "Connection: Keep-Alive" & feed
  67.     strdata = strdata & "Cookie: HMP1=1; " & Cookies(4) & "; MSPDom=; " & Cookies(1) & "; " & Cookies(2) & "; MSPVis=1; LO=;" & feed & feed
  68.     MakeString = strdata
  69. End Select
  70. End Function
  71.