Around Emails & inbox with Gmail and Courrier apps

Published on by Yousfi Benameur


I searched in all vfp namespace a code to grab my gmail box or to send emails.All codes i tried returned me errors (protocoles,...) and dont have capabilities to communicate with actual google gmail.
I searched for an email desktop application.i found a free one named EasyMail for Gmail in windows store(more 9 Moctets free and installed directly without see anything).it contains adds..).
then i make my personal  desktop app from VFP9.
this is a desktop application to work with gmail interface.No need to any classic browser as real navigator.
it uses the internetexplorer application as COM object.

-must have a gmail account mandatory (user@gmail.com and secret password)
-executing code at first time  fires  google login interface  (valid {username+password}).this is needed time to time only for authentification.
-second run it access directly to the mail  gmail interface as draft created....
-in the gmail interface complete manually:attachment(s)+styles (fonts,colors,alignment..), insert images in body ,.... and submit.
the email have sent the apIE window asks to close click yes.
Mailto: supports some commands but never support attachments.

its the better way to work with gmail(semi automatically) otherwise you have protocoles problems,blocked messages,security problems,and so on.
-URL code to build :"http://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&su=SUBJECT&body=BODY&bcc=someone.else@example.com"

-Gmail interface dont support HTML tags but can paste any html rendered part (from clipboard or by copy...).
-can fire the contacts list (with  first authentification)
-the editbox have a contextuel edition menu in rightclick.
-the controls text1 and text2 can filled with rightclick (paste clipboard)
-can set fullscreen mode or no  on apIE with f11.

-can add a config.fpw in a project and compile an exe.its works as well.Same thing with code courrier *2*.
the Gmail option runs on code *1* below

-note : win10/ie11 dont have a mailto to gmail  set by default (its courrier app instead).Outlook is mandatory set by the default and cannot be deleted (others can be deleted !).
can add gmail account and work with (the app is fired by : run/n  mailto: or by shellexecute API)
i dont see any courrier automation anywhere on the web.
can also work with gmail as second option (and add other accounts).it fires courrier interface in all cases.
the courrier option runs  in code *2* below

nor Gmail nor corrier accepts attachments programmatly.that why must work with the visual interface to complete the emails composition.


Click on code to select [then copy] -click outside to deselect


*1* gmail interfaces for emails and inbox
*replace the benameuryousfi1@gmail comm with your real destinataire
*updated on 02/22/2016 06:50:02 PM  added 2 buttons contacts+calendar+update contextuel menu with some usefull google applications.

_Screen.WindowState=1
If !_vfp.StartMode=0
    On Shutdown Quit
Endi
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)

*download the picture used in code.if dont have internet connect , replace by a local image named yimage.jpg
Declare Integer URLDownloadToFile In urlmon.Dll Integer pCaller, String szURL, String szFileName, Integer dwReserved, Integer lpfnCB
Declare Integer DeleteUrlCacheEntry In wininet String lpszUrlName

Local lcDownloadURL,lcDownloadLoc,lnResult
lcDownloadURL = "http://img.over-blog-kiwi.com/1/43/54/07/20160221/ob_31fba8_mail-icon-6338.png"
lcDownloadLoc = "yImage.png"

lnResult = DeleteUrlCacheEntry(lcDownloadURL)
lnResult = URLDownloadToFile(0, lcDownloadURL, lcDownloadLoc , 0,0)
If lnResult = 0
    Wait Window "Download  yimage.png  Complete" Nowait
    *Else
    *!*        Messagebox("Download fails")
Endi

Publi yform
yform=Newobject("ygmail_interface")
yform.Show
Read Events
Retu
*
Define Class ygmail_interface As Form
    Height = 526
    Width = 800
    ShowWindow = 2
    AutoCenter = .T.
    Caption = "-Send email with Gmail interface with authentifications-"
    BackColor = Rgb(212,208,200)
    Name = "Form1"

    Add Object text1 As TextBox With ;
        FontBold = .T., ;
        FontSize = 12, ;
        Anchor = 768, ;
        Value = "My title subject here", ;
        Height = 25, ;
        Left = 69, ;
        SpecialEffect = 2, ;
        Top = 35, ;
        Width = 588, ;
        ForeColor = Rgb(255,0,0), ;
        Name = "Text1"

    Add Object label1 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "Subject", ;
        Height = 17, ;
        Left = 21, ;
        Top = 35, ;
        Width = 45, ;
        BackColor = Rgb(255,255,128), ;
        Name = "Label1"

    Add Object ycont As ycont
    Name="ycont"

    Add Object label2 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "Body", ;
        Height = 17, ;
        Left = 23, ;
        Top = 57, ;
        Width = 30, ;
        BackColor = Rgb(255,255,128), ;
        Name = "Label2"

    Add Object edit1 As EditBox With ;
        FontSize = 12, ;
        Anchor = 15, ;
        Height = 361, ;
        Left = 11, ;
        SpecialEffect = 2, ;
        Top = 101, ;
        Width = 777, ;
        Name = "Edit1"

    Add Object IMAGE1  As Image With ;
        Picture = "yimage.png",;
        anchor=768,;
        Stretch = 2,;
        BackStyle = 1,;
        Height = 61,;
        Left = 690,;
        Top = 5,;
        Width = 85,;
        mousepointer=15, ;
        Name = "Image1"

    Add Object command1 As CommandButton With ;
        Top = 484, ;
        Left = 262, ;
        Height = 37, ;
        Width = 193, ;
        FontSize = 14, ;
        Anchor = 768, ;
        Caption = "Gmail Interface", ;
        MousePointer = 15, ;
        SpecialEffect = 2, ;
        BackColor = Rgb(128,255,0), ;
        Name = "Command1"

    Add Object ycontacts As CommandButton With ;
        Top = 484, ;
        Left = 462, ;
        Height = 37, ;
        Width = 193, ;
        FontSize = 14, ;
        Anchor = 768, ;
        Caption = "My Contacts", ;
        MousePointer = 15, ;
        SpecialEffect = 2, ;
        BackColor = Rgb(128,255,0), ;
        Name = "ycontacts"

    Add Object ycal As CommandButton With;
        Top = 492,;
        Left = 20,;
        Height = 25,;
        Width = 100,;
        FontSize = 12,;
        Anchor = 768,;
        Caption = "My Calendar",;
        MousePointer = 15,;
        SpecialEffect = 2,;
        BackColor = Rgb(255,128,0),;
        Name = "ycal"

    Add Object COMMAND3 As CommandButton With;
        Top = 492,;
        Left = 156,;
        Height = 25,;
        Width = 84,;
        FontSize = 12,;
        Anchor = 768,;
        Caption = "Clear",;
        MousePointer = 15,;
        SpecialEffect = 2,;
        BackColor = Rgb(255,128,0),;
        Name = "Command3"

    Add Object text2 As TextBox With ;
        FontBold = .T., ;
        FontSize = 11, ;
        Anchor = 768, ;
        Value = "benameuryousfi1@gmail.com", ;
        Height = 25, ;
        Left = 128, ;
        SpecialEffect = 2, ;
        Top = 0, ;
        Width = 420, ;
        Themes = .T., ;
        Name = "Text2"

    Add Object label3 As Label With ;
        AutoSize = .T., ;
        FontBold = .T., ;
        Anchor = 768, ;
        Caption = "To", ;
        Height = 17, ;
        Left = 100, ;
        Top = 3, ;
        Width = 16, ;
        BackColor = Rgb(255,255,128), ;
        Name = "Label3"

    Procedure ycontacts.Click
        Local apie
        Local m.lcdest
        m.lcdest="https://contacts.google.com/u/0/preview/all"
        Declare Integer BringWindowToTop In user32 Integer
        apie=Newobject("internetexplorer.application")
        With apie
            .Navigate(m.lcdest)
            .Top=0
            .Left=-5
            .Width=Sysmetric(1)+10
            .Height=Sysmetric(2)
            .menubar=0
            .Toolbar=0
            .StatusBar=0
            BringWindowToTop(.HWnd)
            .Visible=.T.
        Endwith
    Endproc

    Procedure ycal.Click
        Local apie
        Local m.lcdest
        m.lcdest="https://calendar.google.com/calendar/render?tab=wc&pli=1#main_7"
        Declare Integer BringWindowToTop In user32 Integer
        apie=Newobject("internetexplorer.application")
        With apie
            .Navigate(m.lcdest)
            .Top=0
            .Left=-5
            .Width=Sysmetric(1)+10
            .Height=Sysmetric(2)
            .menubar=0
            .Toolbar=0
            .StatusBar=0
            BringWindowToTop(.HWnd)
            .Visible=.T.
        Endwith
    Endproc

    Procedure IMAGE1.MouseEnter
        Lparameters nButton, nShift, nXCoord, nYCoord
        With This
            .Left=.Left-2
            .Top=.Top-2
        Endwith
    Endproc

    Procedure IMAGE1.MouseLeave
        Lparameters nButton, nShift, nXCoord, nYCoord
        With This
            .Left=.Left+2
            .Top=.Top+2
        Endwith
    Endproc

    Procedure Destroy
        Clea Events
    Endproc

    Procedure COMMAND3.Click
        With Thisform
            .text1.Value=""
            .text2.Value=""
            .edit1.Value=""
        Endwith
    Endproc

    Procedure IMAGE1.Click
        Local apie
        Local m.lcdest
        m.lcdest="https://mail.google.com/mail/u/0/#inbox"
        Declare Integer BringWindowToTop In user32 Integer
        apie=Newobject("internetexplorer.application")
        With apie
            .Navigate(m.lcdest)
            .Top=0
            .Left=-5
            .Width=Sysmetric(1)+10
            .Height=Sysmetric(2)
            .menubar=0
            .Toolbar=0
            .StatusBar=0
            BringWindowToTop(.HWnd)
            .Visible=.T.
            *inkey(3)
            *oshell=newObject("wscript.shell")
            *oshell.sendkeys("^{v}") &&paste html rendered for ex on the body email (gmail dont support html tags)
            *oshell=null
        Endwith
    Endproc

    Procedure Init
        Declare Integer AnimateWindow In WIN32API ;
            Integer HWnd, ;
            Integer dwTime, ;
            Integer dwFlags
        #Define AW_BLEND        0x00080000
        AnimateWindow (Thisform.HWnd,5000, AW_BLEND)
    Endproc

    Procedure edit1.Init
        TEXT to this.value noshow
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel risus eget lorem feugiat
2. fermentum nec a turpis. Phasellus purus sem, mollis ac posuere eget, ornare vel orci. Sed ac rutrum
3. nulla. Aenean ultrices eget lectus eu efficitur. In hac habitasse platea dictumst. Nulla in iaculis nisi.
4. Nullam et pulvinar tellus. Donec arcu dui, efficitur a odio non, porta congue dolor. Aenean viverra
5. auctor sagittis. Integer lobortis dignissim auctor. Proin et volutpat massa.
6. Cras vitae felis venenatis, egestas sem quis, sodales neque. Donec venenatis hendrerit odio, non
7. pellentesque metus scelerisque ac. Suspendisse aliquet rhoncus odio id viverra. Vestibulum feugiat
8. lectus a nisl pulvinar, in tempor metus eleifend. Nunc id odio quam. Praesent egestas lorem ut
9. sollicitudin consectetur. Vestibulum id bibendum est. Ut vel lacus sapien. Quisque eget molestie
10. sem. Integer eget purus eu orci molestie aliquam quis in ante. Integer a magna eget lectus finibus
11. porttitor. Donec fringilla sapien a quam aliquet, pellentesque blandit nisl placerat. Nam hendrerit
12. velit vel ex aliquam, eget convallis ante mollis.
13. Maecenas molestie erat sit amet molestie tempor. Donec nec nunc nunc. Vestibulum quis magna
14. vestibulum, vulputate diam ac, varius leo. Duis ac magna eu quam iaculis efficitur. Etiam diam
15. lectus, condimentum sit amet felis a, vehicula fringilla turpis. Aenean quis venenatis dui. Praesent
16. suscipit consequat nunc, vitae ultrices lacus fermentum vitae. Pellentesque ultricies nisl eget
17. maximus elementum. Pellentesque sit amet imperdiet ante. Cras id purus risus.
        ENDTEXT
    Endproc

    Procedure edit1.RightClick
        Define Popup raccourci SHORTCUT Relative From Mrow(),Mcol()
        Define Bar _Med_slcta Of raccourci Prompt "Sélectionner tout" ;
            KEY CTRL+A, "Ctrl+A" ;
            PICTRES _Med_slcta ;
            MESSAGE "Sélectionne tout le texte ou tous les éléments de la fenêtre active"
        Define Bar _Med_paste Of raccourci Prompt "Coller" ;
            KEY CTRL+V, "Ctrl+V" ;
            PICTRES _Med_paste ;
            MESSAGE "Place le contenu du Presse-papiers au point d'insertion"
        Define Bar _Med_copy Of raccourci Prompt "Copier" ;
            KEY CTRL+C, "Ctrl+C" ;
            PICTRES _Med_copy ;
            MESSAGE "Copie la sélection et la place dans le Presse-papiers"
        Define Bar _Med_cut Of raccourci Prompt "Couper" ;
            KEY CTRL+X, "Ctrl+X" ;
            PICTRES _Med_cut ;
            MESSAGE "Enlève la sélection et la place dans le Presse-papiers"
        Define Bar _Med_redo Of raccourci Prompt "Rétablir" ;
            KEY CTRL+R, "Ctrl+R" ;
            PICTRES _Med_redo
        Define Bar _Med_undo Of raccourci Prompt "Annuler" ;
            KEY CTRL+Z, "Ctrl+Z" ;
            PICTRES _Med_undo ;
            MESSAGE "Annule la dernière modification"
        Activate Popup raccourci
    Endproc

    Procedure command1.Click
        Local xto,xsu,xbody,myvar

        xto=Thisform.text2.Value
        xsu=Thisform.text1.Value

        Set Memowidth To 8192
        Local m.xbody,m.X
        m.xbody=Thisform.edit1.Value
        m.X=""
        For i=1 To Memlines(m.xbody)
            m.X=m.X+Mline(m.xbody,i)+"%0D%0A"
        Endfor
        m.xbody=m.X

        TEXT to m.myvar textmerge noshow
https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=<<m.xto>>&su=<<m.xsu>>&body=<<m.xBODY>>&bcc="
        ENDTEXT
        *try also   mailto:https://mail.google.com/mail/u/0/#inbox?compose=new   &&avec shellexecute API
        Thisform.WindowState=1
        Publi apie
        Declare Integer BringWindowToTop In user32 Integer
        apie=Newobject("internetexplorer.application")
        With apie
            .Navigate(m.myvar)
            .menubar=0
            .Toolbar=0
            .StatusBar=0
            .Top=0
            .Left=-5
            .Width=Sysmetric(1)+10
            .Height=Sysmetric(2)
            BringWindowToTop(.HWnd)
            .Visible=.T.
            *if want to paste a seected part of web page or text...
            *inkey(3)
            *oshell=newObject("wscript.shell")
            *oshell.sendkeys("^{v}") &&paste html rendered for ex on the body email (gmail dont support html tags)
            *oshell=null
        Endwith
    Endproc

    Procedure yhelp
        TEXT to m.myvar noshow
this is a desktop application to work with gmail interface .No need to any classic browser.
it uses the internetexplorer application.
-must have a gmail account mandatory
-execute code first time to login (valid {username+password})
-second run it access directly to the mail  gmail interface as draft created....
-complete manually+attachment+styles (fonts,colors,alignment..), insert images in body ,.... and submit.
the email have sent the window asc to close click yes.
its the better way to work with gmail otherwise you have protocoles problems,blocked messages,and so on.
-URL code to build :"http://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&su=SUBJECT&body=BODY&bcc=someone.else@example.com"
-note : win10/ie11 dont have a mailto to gmail .i have, set by default (courrier instead).Outlook is mandatory set by the default.
can add gmail account and work with (the app is fired by : run/n mailto:)
i dont see any courrier automation.
can also work with gmail as second option (and add other accounts).it fires courrier  interface in all cases.
-Gmail interface dont support HTML tags but can paste any html rendered part (from clipboard or by copy...).
-the editbox have a contextuel meny in rightclick.
-the controls text1 and text2 can filled with rightclick (paste clipboard)
-can set fullscreen mode on apIE with f11.
        ENDTEXT

        Declare Integer MessageBox In user32 As MessageBoxA ;
            INTEGER HWnd,;
            STRING  lpText,;
            STRING  lpCaption,;
            INTEGER wType

        #Define MB_ICONINFORMATION 0x00000040
        #Define MB_OK 0x00000000
        #Define MB_APPLMODAL 0x00000000
        #Define  MB_DEFBUTTON1 0x00000000
        =MessageBoxA(Thisform.HWnd,m.myvar,"Summary Help",MB_APPLMODAL+MB_OK +MB_ICONINFORMATION +MB_DEFBUTTON1 )

    Endproc

    Procedure text1.RightClick
        This.Value=_Cliptext
    Endproc

    Procedure text2.RightClick
        This.Value=_Cliptext
    Endproc

    Procedure ynavig
        Lparameters url
        Declare integer Sleep in kernel32 integer
        Declare Integer BringWindowToTop In user32 Integer
        apie=Newobject("internetexplorer.application")
        With apie
            .Navigate(url)
            .Top=0
            .Left=-5
            .Width=Sysmetric(1)+10
            .Height=Sysmetric(2)
            .menubar=0
            .Toolbar=0
            .StatusBar=0
            BringWindowToTop(.HWnd)
            .Visible=.T.
            sleep(3000)
            local oshell
            oshell=newObject("wscript.shell")
            oshell.sendkeys("^{F11}")  &&f11 fullscreen/f11 cut fullscreen
            oshell=null
        Endwith
    Endproc
Enddefine
*
*-- EndDefine: ygmail_interface


Define Class ycont As Container
    Top = 1
    Left = 5
    Width = 73
    Height = 25
    BorderWidth = 0
    MousePointer = 15
    BackColor = Rgb(223,255,191)
    Name = "Container1"

    Add Object line1 As Line With ;
        BorderWidth = 5, ;
        Height = 0, ;
        Left = 4, ;
        Top = 5, ;
        Width = 60, ;
        Name = "Line1"

    Add Object line2 As Line With ;
        BorderWidth = 5, ;
        Height = 0, ;
        Left = 4, ;
        Top = 12, ;
        Width = 60, ;
        Name = "Line2"

    Add Object line3 As Line With ;
        BorderWidth = 5, ;
        Height = 0, ;
        Left = 5, ;
        Top = 20, ;
        Width = 60, ;
        Name = "Line3"

    Procedure RightClick
        This.Click
    Endproc

    Procedure line1.Click
        This.Parent.Click
    Endproc

    Procedure line2.Click
        This.Parent.Click
    Endproc

    Procedure line3.Click
        This.Parent.Click
    Endproc

    Procedure Click
        Define Popup raccourci SHORTCUT Relative From Mrow(),Mcol()
        Define Bar 1 Of raccourci Prompt "Summary help"
        Define Bar 2 Of raccourci Prompt "users mails"
        Define Bar 3 Of raccourci Prompt "Google search"
        Define Bar 4 Of raccourci Prompt "Google Images"
        Define Bar 5 Of raccourci Prompt "Google scholars"
        Define Bar 6 Of raccourci Prompt "Google Translate"
        Define Bar 7 Of raccourci Prompt "Google+"
        Define Bar 8 Of raccourci Prompt "Google Maps"
        Define Bar 9 Of raccourci Prompt "Google News"
        Define Bar 10 Of raccourci Prompt "Google codes"
        Define Bar 11 Of raccourci Prompt "Google Books"
        On Selection Bar 1 Of raccourci _Screen.ActiveForm.yhelp
        On Bar 2 Of raccourci Activate Popup usersmails
        On Selection Bar 3 Of raccourci _Screen.ActiveForm.ynavig("https://www.google.com/intl/fr/insidesearch/")
        On Selection Bar 4 Of raccourci _Screen.ActiveForm.ynavig("https://images.google.dz/imghp?hl=fr")
        On Selection Bar 5 Of raccourci _Screen.ActiveForm.ynavig("https://scholar.google.com/?hl=fr")
        On Selection Bar 6 Of raccourci _Screen.ActiveForm.ynavig("https://translate.google.dz/?hl=fr")
        On Selection Bar 7 Of raccourci _Screen.ActiveForm.ynavig("https://plus.google.com/?utm_source=embedded&utm_medium=googleabout&utm_campaign=link")
        On Selection Bar 8 Of raccourci _Screen.ActiveForm.ynavig("https://www.google.dz/maps/@33.6837582,1.015031,1277m/data=!3m1!1e3?hl=fr")
        On Selection Bar 9 Of raccourci _Screen.ActiveForm.ynavig("https://news.google.dz/nwshp?hl=fr")
        On Selection Bar 10 Of raccourci _Screen.ActiveForm.ynavig("https://code.google.com/intl/fr/")
        On Selection Bar 11 Of raccourci _Screen.ActiveForm.ynavig("https://www.google.com/search?tbm=bks&q=visual foxpro")

        Define Popup usersmails SHORTCUT Relative
        Define Bar 1 Of usersmails Prompt "user1@gmail.com"
        Define Bar 2 Of usersmails Prompt "user2@gmail.com"
        Define Bar 3 Of usersmails Prompt "user3@gmail.com"
        Define Bar 4 Of usersmails Prompt "user4@gmail.com"
        Define Bar 5 Of usersmails Prompt "user5@gmail.com"
        On Selection Bar 1 Of usersmails _Screen.ActiveForm.text2.Value="user1@gmail.com"
        On Selection Bar 2 Of usersmails _Screen.ActiveForm.text2.Value="user2@gmail.com"
        On Selection Bar 3 Of usersmails _Screen.ActiveForm.text2.Value="user3@gmail.com"
        On Selection Bar 4 Of usersmails _Screen.ActiveForm.text2.Value="user4@gmail.com"
        On Selection Bar 5 Of usersmails _Screen.ActiveForm.text2.Value="user5@gmail.com"

        Activate Popup raccourci
    Endproc

Enddefine
*
*-- EndDefine: ycont


last png is used in code.its downloaded from my blog as yimage.png.
last png is used in code.its downloaded from my blog as yimage.png.
last png is used in code.its downloaded from my blog as yimage.png.
last png is used in code.its downloaded from my blog as yimage.png.
last png is used in code.its downloaded from my blog as yimage.png.

last png is used in code.its downloaded from my blog as yimage.png.

 
Courrier is the mail client pre-installed on Windows 10. This feature-rich app allows  to manage emails from different email accounts (Outlook, Google, Yahoo,Exchange ...) directly on a  PC. The Courrier application works in tandem with the application Calendar, which facilitates the creation of new events, calendar reminders,Sync  contacts, and managing  calendar based on  emails.


Click on code to select [then copy] -click outside to deselect


*2* ycourrier.prg
*availabe on mailto default application in windows10
*replace the benameuryousfi1@gmail comm with your real destinataire

_screen.windowstate=1
Publi yform
yform=Newobject("ycourrier")
yform.Show
Read Events
Retu
*
Define Class yCourrier As Form
    Height = 480
	Width = 796
	ShowWindow = 2
	ShowTips = .T.
	AutoCenter = .T.
	Caption = "MS Courrier application (windows 10)"
	BackColor = Rgb(212,208,200)
	yp = .F.

	Add Object label1 As Label With ;
		AutoSize = .T., ;
		Anchor = 768, ;
		Caption = "Object", ;
		Height = 17, ;
		Left = 170, ;
		Top = 60, ;
		Width = 37, ;
		BackColor = Rgb(255,255,128), ;
		Name = "Label1"

	Add Object text1 As TextBox With ;
		FontBold = .T., ;
		Anchor = 768, ;
		Height = 27, ;
		Left = 218, ;
		SpecialEffect = 2, ;
		Top = 48, ;
		Width = 538, ;
		Name = "Text1"


	Add Object edit1 As EditBox With ;
		Anchor = 15, ;
		Height = 288, ;
		Left = 160, ;
		SpecialEffect = 2, ;
		Top = 112, ;
		Width = 632, ;
		Name = "Edit1"

	Add Object label2 As Label With ;
		AutoSize = .T., ;
		Caption = "Body", ;
		Height = 17, ;
		Left = 180, ;
		Top = 89, ;
		Width = 29, ;
		BackColor = Rgb(255,255,128), ;
		Name = "Label2"


	Add Object command2 As CommandButton With ;
		Top = 420, ;
		Left = 360, ;
		Height = 49, ;
		Width = 171, ;
		FontBold = .T., ;
		FontSize = 12, ;
		Anchor = 768, ;
		Caption = "Courrier Interface", ;
		SpecialEffect = 2, ;
		ForeColor = Rgb(255,0,0), ;
		BackColor = Rgb(255,128,64), ;
		Name = "Command2"

	Add Object command3 As CommandButton With ;
		Top = 432, ;
		Left = 144, ;
		Height = 27, ;
		Width = 74, ;
		FontBold = .T., ;
		FontSize = 12, ;
		Anchor = 768, ;
		Caption = "Courrier ", ;
		SpecialEffect = 2, ;
		BackColor = Rgb(128,255,0), ;
		Name = "Command3"

	Add Object label3 As Label With ;
		AutoSize = .T., ;
		Anchor = 768, ;
		Caption = "Email to", ;
		Height = 17, ;
		Left = 173, ;
		Top = 11, ;
		Width = 47, ;
		BackColor = Rgb(255,255,128), ;
		Name = "Label3"

	Add Object text2 As TextBox With ;
		FontBold = .T., ;
		FontSize = 10, ;
		Anchor = 768, ;
		Height = 27, ;
		Left = 228, ;
		SpecialEffect = 2, ;
		Top = 5, ;
		Width = 469, ;
		ForeColor = Rgb(128,0,64), ;
		Name = "Text2"

	Add Object ycont1 As ycont With ;
		Anchor = 768, ;
		Top = 5, ;
		Left = 15, ;
		Width = 73, ;
		Height = 25, ;
		BorderWidth = 0, ;
		MousePointer = 15, ;
		BackColor = Rgb(128,255,0), ;
		ToolTipText = "Emails of customers", ;
		Name = "ycont"

	Add Object list1 As ListBox With ;
		Height = 351, ;
		Left = 3, ;
		SpecialEffect = 2, ;
		Top = 53, ;
		Width = 153, ;
		Name = "List1"

	Procedure Activate
	DoDefault()
	Thisform.ycont.Click
	Endproc

	Procedure text1.RightClick
	This.Value=_Cliptext
	Endproc
    
    Procedure init
    Declare Integer AnimateWindow In WIN32API ;
    Integer HWnd, ;
    Integer dwTime, ;
	Integer dwFlags
   #Define AW_BLEND        0x00080000
   AnimateWindow (Thisform.HWnd,5000, AW_BLEND)
   endproc

	Procedure text1.Init
	This.Value="this is a test of courrier application"
	Endproc

	Procedure edit1.RightClick
	Define Popup raccourci SHORTCUT Relative From Mrow(),Mcol()
	Define Bar _Med_slcta Of raccourci Prompt "Sélectionner tout" ;
		KEY CTRL+A, "Ctrl+A" ;
		PICTRES _Med_slcta ;
		MESSAGE "Sélectionne tout le texte ou tous les éléments de la fenêtre active"
	Define Bar _Med_paste Of raccourci Prompt "Coller" ;
		KEY CTRL+V, "Ctrl+V" ;
		PICTRES _Med_paste ;
		MESSAGE "Place le contenu du Presse-papiers au point d'insertion"
	Define Bar _Med_copy Of raccourci Prompt "Copier" ;
		KEY CTRL+C, "Ctrl+C" ;
		PICTRES _Med_copy ;
		MESSAGE "Copie la sélection et la place dans le Presse-papiers"
	Define Bar _Med_cut Of raccourci Prompt "Couper" ;
		KEY CTRL+X, "Ctrl+X" ;
		PICTRES _Med_cut ;
		MESSAGE "Enlève la sélection et la place dans le Presse-papiers"
	Define Bar _Med_redo Of raccourci Prompt "Rétablir" ;
		KEY CTRL+R, "Ctrl+R" ;
		PICTRES _Med_redo
	Define Bar _Med_undo Of raccourci Prompt "Annuler" ;
		KEY CTRL+Z, "Ctrl+Z" ;
		PICTRES _Med_undo ;
		MESSAGE "Annule la dernière modification"
	Activate Popup raccourci
	Endproc

	Procedure edit1.Init
	subject=Thisform.text1.Value
	TEXT to thisform.edit1.value noshow
		1.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel risus eget lorem feugiat
		2.fermentum nec a turpis. Phasellus purus sem, mollis ac posuere eget, ornare vel orci. Sed ac rutrum
		3.nulla. Aenean ultrices eget lectus eu efficitur. In hac habitasse platea dictumst. Nulla in iaculis nisi.
		4.Nullam et pulvinar tellus. Donec arcu dui, efficitur a odio non, porta congue dolor. Aenean viverra
		5.auctor sagittis. Integer lobortis dignissim auctor. Proin et volutpat massa.
		6.Cras vitae felis venenatis, egestas sem quis, sodales neque. Donec venenatis hendrerit odio, non
		7.pellentesque metus scelerisque ac. Suspendisse aliquet rhoncus odio id viverra. Vestibulum feugiat
		8.lectus a nisl pulvinar, in tempor metus eleifend. Nunc id odio quam. Praesent egestas lorem ut
		9.sollicitudin consectetur. Vestibulum id bibendum est. Ut vel lacus sapien. Quisque eget molestie
		10.sem. Integer eget purus eu orci molestie aliquam quis in ante. Integer a magna eget lectus finibus
		11.porttitor. Donec fringilla sapien a quam aliquet, pellentesque blandit nisl placerat. Nam hendrerit
		12.velit vel ex aliquam, eget convallis ante mollis.
		13.Maecenas molestie erat sit amet molestie tempor. Donec nec nunc nunc. Vestibulum quis magna
		14.vestibulum, vulputate diam ac, varius leo. Duis ac magna eu quam iaculis efficitur. Etiam diam
		15.lectus, condimentum sit amet felis a, vehicula fringilla turpis. Aenean quis venenatis dui. Praesent
		16.suscipit consequat nunc, vitae ultrices lacus fermentum vitae. Pellentesque ultricies nisl eget
		17.maximus elementum. Pellentesque sit amet imperdiet ante. Cras id purus risus.

	ENDTEXT
	Endproc


	Procedure command2.Click
	lcmail="benameuryousfi1@gmail.com"
	m.subject=Thisform.text1.Value
	m.lcbody=Thisform.edit1.Value

	m.X=""
	For i=1 To Memlines(m.lcbody)
		m.X=m.X+Mline(m.lcbody,i)+"%0D%0A"       &&line breaksyntax in mailto
	Endfor
	m.lcbody=m.X+Spac(40)+"%0D%0A"

	Declare Integer ShellExecute ;
		IN SHELL32.Dll ;
		INTEGER nWinHandle,;
		STRING cOperation,;
		STRING cFileName,;
		STRING cParameters,;
		STRING cDirectory,;
		INTEGER nShowWindow

	m.action="mailto:" + lcmail + ;
		"?subject="+subject + ;
		"&body=" + lcbody+"%0D%0A"
* "attachments:"+"%0D%0A" +"&attachment="+m.attached   &&dont work with attachments (as gmail email interface)

	Return ShellExecute( 0, "Open",m.action  , "", "", 1 )
	Endproc

	Procedure command3.Click
	Declare Integer ShellExecute In shell32.Dll ;
		INTEGER hndWin, String cAction, String cFileName, ;
		STRING cParams, String cDir, Integer nShowWin
	lcmail = "mailto:benameuryousfi1@gmail.com"
	ShellExecute(0,"open",lcmail,"","",1)
	Endproc

	Procedure text2.Init
	This.Value="benameuryousfi1@gmail.com"
	Endproc

	Procedure list1.Init
	Sele company From Home(1)+"samples\data\customer" Into Cursor ycurs

	With This
		.RowSource = "ycurs.company"   &&bind with emails of destinataires
		.RowSourceType=2
		.Visible=.T.
		.SelectedItemBackColor=Rgb(70,60,50)
		.SelectedItemForeColor=Rgb(10,191,160)
		.SpecialEffect=1
		.FontSize=10
		.ItemBackColor=Rgb(40,40,40)
		.ItemForeColor=Rgb(255,204,153)
		.BorderColor=Rgb(235,132,0)
		.ItemTips=.T.
		.MousePointer=15
		.Left=-.Width
	Endwith
	Endproc

	Procedure list1.Click
	Thisform.text2.Value=Strtran(This.Value," ","")+"@gmail.com"
	Endproc

    Procedure destroy
    clea events
    endproc

Enddefine
*
*-- EndDefine: ycourrier


Define Class ycont As Container
	Anchor = 768
	Top = 5
	Left = 15
	Width = 73
	Height = 25
	BorderWidth = 0
	MousePointer = 15
	BackColor = Rgb(128,255,0)
	ToolTipText = "Emails of customers"
	Name = "Container1"

	Add Object line1 As Line With ;
		BorderWidth = 5, ;
		Height = 0, ;
		Left = 4, ;
		Top = 5, ;
		Width = 60, ;
		Name = "Line1"

	Add Object line2 As Line With ;
		BorderWidth = 5, ;
		Height = 0, ;
		Left = 4, ;
		Top = 11, ;
		Width = 60, ;
		Name = "Line2"

	Add Object line3 As Line With ;
		BorderWidth = 5, ;
		Height = 0, ;
		Left = 5, ;
		Top = 17, ;
		Width = 60, ;
		Name = "Line3"

	Procedure Click
	m.delta=20

	If Thisform.yp=.F.
		Thisform.yp=.T.

		With Thisform.list1
			Do While  .Left<=0
				.Left=.Left+m.delta
				Inke(0.1)
			Enddo
			.Left=0
		Endwith

	Else

		Thisform.yp=.F.
		With Thisform.list1
			Do While .Left+.Width>0
				.Left=.Left-m.delta
				Inke(0.1)
			Enddo
			.Left=-.Width
		Endwith
	Endi
	Endproc

	Procedure line1.Click
	This.Parent.Click
	Endproc

	Procedure line2.Click
	This.Parent.Click
	Endproc

	Procedure line3.Click
	This.Parent.Click
	Endproc
	
Enddefine
*
*-- EndDefine:ycont



Note: Insert image in email-courrier allows to choose an image from local disc-Gmail allows web url only (or google+ personal stored images).
Note: Insert image in email-courrier allows to choose an image from local disc-Gmail allows web url only (or google+ personal stored images).
Note: Insert image in email-courrier allows to choose an image from local disc-Gmail allows web url only (or google+ personal stored images).
Note: Insert image in email-courrier allows to choose an image from local disc-Gmail allows web url only (or google+ personal stored images).

Note: Insert image in email-courrier allows to choose an image from local disc-Gmail allows web url only (or google+ personal stored images).

Click on code to select [then copy] -click outside to deselect


*3* a basic code for courrier application.it accepts standard mailto: commands but no attachments.
*send a mail to xxxxx.@gmail.com with MS courrier application (default in windows10)
*%0D%0A" is equivalent to chr(13)+chr(10).
*fires the courrier app new mail with some prefilled fields:

Local lcTO,lcSubject,lcBody,action
lcTO="benameuryousfi1@gmail.com"
lcSubject="This is a demo form new mail"
lcBody=Repli("this is a new body in courrier app"+"%0D%0A",20)

Declare Integer ShellExecute ;
    IN SHELL32.Dll ;
	INTEGER nWinHandle,;
	STRING cOperation,;
	STRING cFileName,;
	STRING cParameters,;
	STRING cDirectory,;
	INTEGER nShowWindow

m.action="mailto:" +m.lcTO+"?subject="+m.lcSubject+"&body="+m.lcBody+"%0D%0A"
Return ShellExecute( 0, "Open",m.action , "", "", 1 )


*to run the courrier interface only  can use this code
*run/n explorer mailto:


Click on code to select [then copy] -click outside to deselect


*4* show gmail inbox on a top level form
*must have a google account with  authentificaion (username+password).its asked first time.
*show the gmail inbox on the vfp form with valid username a    nd password
Publi yform
yform=Newobject("yGmail")
yform.Show
Read Events
Retu
*
Define Class yGmail As Form
	BorderStyle = 3
	Height = 522
	Width = 874
	ShowWindow = 2
	AutoCenter = .T.
	Caption = "yGmail"
	Name = "Form1"

	Add Object olecontrol1 As OleControl With ;
		Oleclass="shell.explorer.2", ;
		Top = -67, ;
		Left = 0, ;
		Height = 588, ;
		Width = 876, ;
		Anchor = 15, ;
		Name = "Olecontrol1"

	Procedure Destroy
	Clea Events
	Endproc

	Procedure olecontrol1.Init
	This.silent=.T.
	This.Navigate("https://mail.google.com/mail/u/0/#inbox")   &&gmail user inbox with authentification (username+password)
* https://mail.google.com/mail/ – Gmail canonical URI which is the URI you most likely to see after login to Gmail webmail interface. This URL can be used on PC as well as portable mobile phone devices. It becomes simple HTML mode depending  on the browser used to access it.
	Endproc

Enddefine
*
*-- EndDefine: ygmail


Click on code to select [then copy] -click outside to deselect


*5*
*can make the gmail inbox as a feed in any navigator.the feeds can be synchronized with inbox source by the user
*(for ex all 1 hour).
*can copy the feed link in the personal navigator bar and then see all what in gmail inbox : click "Subscribe to this feed" to add it on personal navigator bar.

Declare Integer BringWindowToTop In user32 Integer
Publi apie
apie=Newobject("internetexplorer.application")
With apie
    .Navigate("https://mail.google.com/mail/feed/atom")   &&accepted and fires dialog logging.
*https://USERNAME:PASSWORD@gmail.google.com/gmail/feed/atom :this works on Firefox and retrieve xml file.(no longer on IE)

	.menubar=1
	.Toolbar=1
	.StatusBar=1
	.Width=800
	.Height=600
	.Left=(Sysmetric(1)-.Width)/2
	.Top=(Sysmetric(2)-.Height)/2
	BringWindowToTop(.HWnd)
	.Visible=.T.
Endwith



Around Emails &amp; inbox with Gmail and Courrier apps

this plugin maybe interesting
http://add0n.com/fastest-gmail.html
Gmail™ Notifier Plus is a highly customizable browser extension that notifies you about the incoming emails
from all your Google-Mail accounts and labels. Gmail notifier is available for Firefox, and Opera.

(this is available until it be broken as all cloud things)

Important:All Codes above are tested on VFP9SP2 & windows 10 pro & IE11 emulation. To avoid some problems with priveleges level, run vfp9.exe as administrator.

To be informed of the latest articles, subscribe:
Comment on this post
G
Hi,<br /> Thanks for the information about this Really nice Post.
Reply