Connecting to GMail inbox

Just starting out? Need help? Post your questions and find answers here.
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Connecting to GMail inbox

Post by Blue »

I want to write a simple app to access my GMail inbox directly, using PB's Web Gadget.
It works fine with my OutLook inbox, but with GMail, no success.

Anybody with a helpful suggestion ?

The embryonic code I use is as follows :

Code: Select all

EnableExplicit

Define.s gmail
; gmail = "https://mail.google.com/mail/inbox"
gmail = "https://mail.google.com/mail/u/0/#inbox"
gmail = "https://outlook.live.com/mail/#/inbox"

Procedure NavigationCallback(gadget, Url$) 
  ; This example does display the PureBasic.com website. Inside the callback procedure
  ; the navigation to the 'News' site will be avoided (#False returned), but allowed
  ; for all other sites (#True returned).
   If Url$= "http://www.purebasic.com/news.php" 
      MessageRequester("", "No news today!") 
      ProcedureReturn #False 
   EndIf

   ProcedureReturn #True 
EndProcedure 

If 0 = OpenWindow(0, 0, 0, 1024, 1000, "GMail", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   End
EndIf

WebGadget(0, 10, 10, 1000, 980, gmail) 
SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow 
Thanks in advance.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Connecting to GMail inbox

Post by davido »

@Blue,
You might find some help in the following thread:

http://www.purebasic.fr/english/viewtop ... 84#p475184
DE AA EB
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Connecting to GMail inbox

Post by firace »

Try this:

Code: Select all

Define.s keyName, dwLabel, statusMsg, keyResult.i
Define.l dwValue, dwValueCheck, bufferSize

keyName = "Software\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Browser_Emulation\"
dwLabel = GetFilePart(ProgramFilename())
dwValue = 11001
bufferSize = SizeOf(Long)

RegOpenKeyEx_(#HKEY_CURRENT_USER, keyName, 0, #KEY_ALL_ACCESS, @keyResult) 
RegSetValueEx_(keyResult, @dwLabel, 0, #REG_DWORD, @dwValue, SizeOf(Long))


OpenWindow(0, 0, 0, 980, 650, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
WebGadget (0, 0, 0, 980, 650, "")
SetGadgetItemText(0, #PB_Web_HtmlCode, "<META  HTTP-EQUIV='Refresh' CONTENT='0; URL=https://mail.google.com/mail/u/0/#inbox'>")
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow :      Break
    Case #PB_Event_SizeWindow :    ResizeGadget(0, 0,0, WindowWidth(0),WindowHeight(0))
  EndSelect
ForEver
Last edited by firace on Sun Apr 01, 2018 8:47 am, edited 1 time in total.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Connecting to GMail inbox

Post by Dude »

firace, that doesn't work. The page responds with "Oops! You seem to be using an unsupported browser".

[Edit] Weird, running your code a second time shows my Gmail Inbox in Basic HTML mode. :shock: So yeah, it kinda works.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Connecting to GMail inbox

Post by firace »

Dude wrote:firace, that doesn't work. The page responds with "Oops! You seem to be using an unsupported browser".

[Edit] Weird, running your code a second time shows my Gmail Inbox in Basic HTML mode. :shock: So yeah, it kinda works.
You should be able to switch to the standard UI from the bottom of the page.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Connecting to GMail inbox

Post by Dude »

firace wrote:You should be able to switch to the standard UI from the bottom of the page.
There's no such option:

Image
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Connecting to GMail inbox

Post by Blue »

davido wrote:@Blue,
You might find some help in the following thread:

http://www.purebasic.fr/english/viewtop ... 84#p475184
Thanks Davido for your suggestion.
I had already looked at NetMaestro's workaround, but it does not apply to launching GMail. Only to handling messages to be sent (if I understand correctly, of course)
Last edited by Blue on Mon Mar 19, 2018 8:39 pm, edited 2 times in total.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Connecting to GMail inbox

Post by Blue »

firace wrote:Try this:

Code: Select all

...
Repeat
ForEver
...
Thank you very much, Firace
That works very nicely.
But what a circumvoluted way to get such a simple thing done !
I'm going to take the time to look very closely at your code to figure out how and why it works. I find it most intriguing. Thank God (or maybe simply firace...;>), it's very short.
If you have the time and the patience, I'd love to know how you came upon this unexpected solution.
If you know of a Web reference explaining this, that will do it too.

____________________________________________________
Hi Dude
On my system, firace's code worked flawlessly the first time around. Plus it displays normally, in the regular GMail style (i.e. not the barebones HTML you say you're getting).
Simply different settings maybe ?
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Connecting to GMail inbox

Post by firace »

@Blue: Glad it works for you. I'm just forcing the WebGadget to render in IE11 mode (which it doesn't by default).

@Dude: I've fixed a small bug in my post, which could be related. (You may also need to sign out and back into Gmail)
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Connecting to GMail inbox

Post by Dude »

Hi firace, I tried signing out and back in again, but still the usual low-bandwidth HTML look. :(
Post Reply