1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Automating Gmail

Discussion in 'Visual Basic .NET' started by doseph, Jul 9, 2009.

  1. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    The way I see it, there are 2 ways of automating gmail, but both have their drawbacks.

    The first way is to use a Web Browser control, load up gmail and fill the forms programmatically in order to log in. This method is really easy, and it might even still work if gmail changes their code. The problem is that it seems impossible to multithread this approach, the reason being that whenever you implement another webbrowser control, it acts like a new tab rather than a separate window, meaning it will only manage one gmail login at a time.

    The second way would be to use HTTP requests to send the raw login info to gmail, behind the scenes. This is what I've used for a few other sites, however I have never been able to log into gmail and maintain a session without a webbrowser. The advantages of this code would be that you can multithread it quite easily once you have it working, and that it is just very fast and efficient code. The downside would be that you would have to keep on top of updates to make sure they don't change something small on you, rendering your code useless.


    Now, the reason I started this thread is because I'm at a bit of an impasse. I wouldn't mind going with the webbrowser approach, but I would like to multithread it! I also wouldn't mind the HTTP request approach, but I simply can't get it to work!

    So what I'm asking is 2 questions.

    1. Do you know how to load more than one webbrowser into the same application, yet maintain separate sessions?

    OR

    2. Do you know how to access gmail through http requests and maintain a session?


    Hopefully we can get an answer to this up here, because I'm sure there are a lot of other BH coders who are dealing with exactly the same issue, and there's not a whole lot of help available online regarding this issue.
     
  2. Botwiz

    Botwiz Executive VIP Jr. VIP

    Joined:
    Apr 24, 2009
    Messages:
    4,147
    Likes Received:
    2,033
    Occupation:
    Classified
    Location:
    Classified
    2 option isn't available with out sms blocking, vs option 1 can work.

    There are a lot of new gmail tricks that they pulled out of there hats.

    Just let me make my accounts google. WTF
     
  3. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    What do you mean by sms blocking?
     
  4. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    Also, the more I look into it, the more I feel it is just not possible to have multiple webbrowsers in the same windows process maintaining different sessions.

    That leaves us with 2 options that I can think of:

    1.) Maybe there is another web browser control out there (mozilla based?) which might allow us to run multiple sessions

    or

    2.) Create a program that runs as a separate process and runs from the command line. The program would log in, perform the desired task, and then close. The problem with this is that if you wanted to run 20 "threads", they would all show up in your task manager, and all take up a bunch of memory. (a lot more than making it separate threads would)
     
  5. weaselstomp

    weaselstomp Registered Member

    Joined:
    Oct 29, 2008
    Messages:
    86
    Likes Received:
    450
    Location:
    Florida
    Home Page:
    POP is also an option for GMail accounts. It has to be enabled on each account though. There are apps available that do this for a list of GMail accounts. Maybe it's something you could incorporate into your app :)
     
    • Thanks Thanks x 1
  6. pavan_buzz

    pavan_buzz Junior Member

    Joined:
    Jul 25, 2009
    Messages:
    169
    Likes Received:
    115
    Occupation:
    Freelancer
    Location:
    Internet
    Hi mate.. I think you are asking for creating a gmail account. Well for that i think using HttpWebRequest and HttpWebResponse classes would be the best suggestions mate.. U can have a set of cookies to hold the session. With every request u have to attach the cookie .And the property is called CookieContainer. U have to attach the cookie container to each request. Hope this helps.. :)
     
  7. iPwnJ00

    iPwnJ00 Junior Member

    Joined:
    Mar 10, 2009
    Messages:
    132
    Likes Received:
    21
    Location:
    Melbourne, Australia
    I've been working on a project which is a GMail Delayed Autoresponder. It's written in C# but I can't be screwed finishing it at the moment. If you'd like, I can share it here.
     
  8. SupraFast

    SupraFast Junior Member

    Joined:
    Jun 24, 2009
    Messages:
    151
    Likes Received:
    34
    Why are you going through all of this hassle lol? Why not just follow the standard pop3 and smtp protocols.
     
  9. popzzz

    popzzz Supreme Member

    Joined:
    Apr 12, 2009
    Messages:
    1,337
    Likes Received:
    13,699
    Location:
    Don't touch the REP!


    Just forward the gmail's to one account for processing .....

    K.I.S.S. .....

    HTH .... :cool2:
     
  10. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    The reason is that gmail's webmail doesn't send your IP through, whereas smtp does.
     
  11. popzzz

    popzzz Supreme Member

    Joined:
    Apr 12, 2009
    Messages:
    1,337
    Likes Received:
    13,699
    Location:
    Don't touch the REP!
    Send it back out through gmail .....

    Code:
    http://mail.google.com/support/bin/answer.py?answer=13287

    HTH .... :cool2:

     
    • Thanks Thanks x 1
  12. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    Right, but that will include your IP in the header, which could spamlist your emails.
     
  13. popzzz

    popzzz Supreme Member

    Joined:
    Apr 12, 2009
    Messages:
    1,337
    Likes Received:
    13,699
    Location:
    Don't touch the REP!
    How are you spamming when you are ANSWERING emails sent to you??? :wt:

    HTH .... :cool2:

     
  14. doseph

    doseph Registered Member

    Joined:
    Feb 23, 2008
    Messages:
    86
    Likes Received:
    24
    Home Page:
    who says I'm answering emails? :D
     
  15. popzzz

    popzzz Supreme Member

    Joined:
    Apr 12, 2009
    Messages:
    1,337
    Likes Received:
    13,699
    Location:
    Don't touch the REP!
    ASSumed you were ..... :D

    HTH .... :cool2: