Monday, 6 January 2014

SIMPLE DESKTOP GMAIL APPLICATION

1/06/2014 05:28:00 am

                   
                                        This is a simple app to send mail via gmail right from your desktop. Just you can enter your Username, Password, To, Subject, Body and send mail by just one click. So here we go!!

A Video demonstrating it.........



And here's the code....

;Libraries.....
#include <WinAPI.au3>
#include <IE.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
;Variables.....
Global $sUser, $sPwd, $sTo, $sSubject, $sBody

;Creating GUI for inputs...

$Window = GUICreate("Gmail", 500, 400, 200, 100)
$Label1 = GUICtrlCreateLabel("Email ID:", 8, 8, 100, 17)
$Input1 = GUICtrlCreateInput("@gmail.com", 175, 8, 217, 31)
 GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Label2 = GUICtrlCreateLabel("Password", 8, 58, 1000, 17)
$Input2= GUICtrlCreateInput("", 175, 58, 217, 31, $ES_PASSWORD)
 GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$Label3 = GUICtrlCreateLabel("To", 8, 108, 1000, 17)
$Input3 = GUICtrlCreateInput("", 175, 108, 217, 31)
$Label4 = GUICtrlCreateLabel("Subject", 8, 158, 1000, 17)
$Input4 = GUICtrlCreateInput("", 175, 158, 217, 31)
$Label5 = GUICtrlCreateLabel("Body", 8, 208, 1000, 17)
$Input5 = GUICtrlCreateInput("", 175, 208, 217, 151)
$Go = GUICtrlCreateButton("Send", 395, 8, 89, 25, 0)
GUISetState(@SW_SHOW)

;Reading Inputs....

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Go
$sUser = GUICtrlRead($Input1)            
$sPwd = GUICtrlRead($Input2)    
$sTo = GUICtrlRead($Input3)    
$sSubject = GUICtrlRead($Input4)    
$sBody = GUICtrlRead($Input5)    
    ExitLoop
    EndSwitch
    WEnd

;Navigating to Internet Explorer to login and send email..
;You can set the 3rd argument to 0 from 1 if you donot wish to see the mail being sent...
;Like opening of browser.. .
$oIE = _IECreate("https://accounts.google.com/ServiceLogin?service=mail&?ui=html&zy=h",0,1)
;Waiting till it loads
        _IELoadWait($oIE)
;Getting the form fields
$oForm = _IEFormGetObjByName($oIE, "gaia_loginform")
$oUser = _IEFormElementGetObjByName($oForm, "Email")
        $oPwd = _IEFormElementGetObjByName($oForm, "Passwd")
$oChkbx = _IEFormElementGetObjByName($oForm, "PersistentCookie")
$oButton = _IEFormElementGetObjByName($oForm, "signIn")
;Setting the username, pwd ....
_IEFormElementSetValue($oUser, $sUser)
_IEFormElementSetValue($oPwd, $sPwd)
_IEAction($oChkbx, "click")
_IEAction($oButton, "click")
 _IELoadWait($oIE)
 ;Navigating to "compose mail"
 _IENavigate($oIE,"https://mail.google.com/mail/h/?&v=b&pv=tl&cs=b")
 _IELoadWait($oIE)
 ;Getting the fields to fill in for sending the mail
 $oForm1 = _IEFormGetObjByName($oIE, "f")
 $oTo = _IEFormElementGetObjByname($oForm1, "to")
 $oSubject = _IEFormElementGetObjByname($oForm1, "subject")
$oBody = _IEFormElementGetObjByname($oForm1, "body")
$oSendButton = _IEFormElementGetObjByname($oForm1, "nvp_bu_send")
;Entering the details of mail to be sent
 _IEFormElementSetValue($oTo, $sTo)
_IEFormElementSetValue($oSubject, $sSubject)
_IEFormElementSetValue($oBody, $sBody)
_IEAction($oSendButton, "click")
_IELoadWait($oIE)
;Quit IE
_IEQuit($oIE)
;Quit program
Exit 

You can also download the code from here

Written by

1 comments:

 

© 2013 The Repository. All rights resevered. Designed by Templateism

Back To Top