Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Visual-Studio HTML DOM , +
I'm trying to FORWARD and email from GMAIL using the WebBrowserControl (C#).
 
-I am able to open the Gmail INBOX page on the WebBrowserControl...
-I am able to OPEN the specific email (among the others on the inbox) that I need to forward...
-I am able to find and click the FORWARD link to start working with the email fields (TEXTS)...
-I am able to add/insert the email that I would like to send TO...
-I am able to add/edit the content of the email body...
 
However, now that I am done with the email I CAN'T SEND IT. I need to invoke/click the SEND button but Gmail uses DIV instead of BUTTONS and the regular CLICK does not work.
 
This is what I did so far. Since most of the DIVs do not have ID, I iterate through all the DIVs inside the Gmail MAIN FRAME (canvas_frame)....
 
webIE.Document.Window.Frames["canvas_frame"].Document.Body.GetElementsByTagName( "div" );
...and with a regular expression I was able to find the right DIV that contains the text(SEND) that I need to click. Here is the sample on how GMAIL encapsulates the HTML 'SEND' BUTTON = DIV (the same apply to most of the buttons like SAVE NOW, DISCARD, etc).
<div id=":j5" class="J-K-I J-J5-Ji Bq L3" role="button" tabIndex="1" unselectable="on">
    <div class="J-J5-Ji J-K-I-Kv-H" unselectable="on">
        <div class="J-J5-Ji J-K-I-J6-H" unselectable="on">
            <div class="J-K-I-KC" unselectable="on">
                <div class="J-K-I-K9-KP" unselectable="on"> </div>
                <div class="J-K-I-Jz" unselectable="on">Send</div>
            </div>
        </div>
    </div>
</div>
I first tried invoking click ( InvokeMember("click") ) on the inner DIV containing the SEND text:
<div class="J-K-I-Jz" unselectable="on">Send</div>
...but unfortunately did not work, then I tried invoking click on all and any of the DIVs (Parent/Children) of the above HTML code with no luck at all.
 
Any IDEA/ADVICE on how can I get to SEND the email?
 
++Thanks
Posted 10-Jan-12 5:25am
Comments
South 305 at 10-Jan-12 18:18pm
   
@shoputer
------------------
Yes, kinda automate, and the main reason on why I decided to use the WebBrowserControl instead of any other API is that I need to keep the history on the account as if I did (answered/forwarded) by myself. I mean the original email and the answered threads (as Gmail groups the emails).
 
I know that everything depend on the Gmail Layout that is why I am using the old look and is worthy. I can login on a gmail accounts and with one click I can send a customize answered (1 by 1) to lots of customers. And as I mentioned, keeping the history for reference and organization matters.
 
I am familiar with the GMAIL SMTP and I use that with some other C# apps but in this case I really need to hit the SEND (DIV)... lol
 
Thanks anyways...

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

First of all, this is probably not the kind of answer you'd expect.
 
As far as I understand your problem, you're trying to automate the process of forwarding an e-mail, isn't it? What are you doing in case Google decides to change their layout?
 
In my opinion it would be better and hopefully easier if you're trying to connect to your GMail account via IMAP, querying for the message you want to forward, download and modify it and finally resend it via SMTP (through Google Mail).
 
There is already a SMTP client[^] built into the .NET framework. Unfortunately you have to look for an external library which lets you browse your inbox via IMAP. I found this one[^]. I don't know if there are others, probably yes.
 
Just my thoughts.
  Permalink  
Comments
SAKryukov at 10-Jan-12 14:52pm
   
Makes sense, useful link; I voted 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 10 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100