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

C#: Click an email in Hotmail using the Web browser?

Discussion in 'C, C++, C#' started by kytro360, Oct 23, 2011.

Tags:
  1. kytro360

    kytro360 Power Member

    Joined:
    Jan 12, 2010
    Messages:
    710
    Likes Received:
    734
    Hello everyone. I need a little help with a bit of code cause Hotmail is acting weird. What I am trying to do is make my bot click an email inside of Hotmail.

    The code I have should work but it isnt clicking on anything so I wanted to ask here if anyone can help me out to make it work :).

    Ive only included the portion to click on the email. If you can provide any help, I would be truly grateful:

    Code:
    
     if (webBrowser1.Url.AbsoluteUri.Contains("mail/InboxLight.aspx"))
     {                           
    
    HtmlElementCollection allelements = webBrowser1.Document.GetElementsByTagName("a"); 
    
    foreach (HtmlElement element in allelements) 
    
    {
    
     if (element.GetAttribute("value").Contains("Hotmail getting started tip #1: Add contacts"))                             {                                  element.InvokeMember("click");                             } 
    
    }
    
    
    
     
  2. ~divinci

    ~divinci Registered Member

    Joined:
    Sep 23, 2009
    Messages:
    51
    Likes Received:
    11
    Occupation:
    Infastructure Reverse Engineer
    Location:
    Liverpool UK
    WatIn is so easy for this type of thing, Use it you might be able to attach it to your webbrowser control instance to save any code refactoring.

    Syntax would be somethin like this

    ie.Document.Links.Filter(Find.ByText("Hotmail getting started blahblah")).First.Click();

    Beautiful syntax
     
  3. kokoloko75

    kokoloko75 Elite Member

    Joined:
    Jan 1, 2011
    Messages:
    1,628
    Likes Received:
    1,940
    Occupation:
    Design director
    Location:
    Paris (France)
    To click on link in WebBrowser, in Delphi I use this :
    Code:
    http://www.delphipages.com/forum/showthread.php?t=118008
    Maybe it can help you...

    Beny
     
  4. Aremys

    Aremys Regular Member

    Joined:
    Sep 13, 2008
    Messages:
    307
    Likes Received:
    72
    I use this for email related projects:

    Code:
    http://sourceforge.net/projects/hpop/
     
  5. Aremys

    Aremys Regular Member

    Joined:
    Sep 13, 2008
    Messages:
    307
    Likes Received:
    72
    I use this for email related projects:

    Code:
    http://sourceforge.net/projects/hpop/
     
  6. Stalli0n

    Stalli0n Junior Member

    Joined:
    Nov 17, 2010
    Messages:
    115
    Likes Received:
    83
    Location:
    Europe
    Of course it can help him, if he would program in delphi, but he uses C# for fucks sake...

    I think the reason your code is not working is that hotmail uses Ajax.
    My advice is you forget the Webbrowser, its shit anyways and use something good like Selenium or WatIn.