0

I want to create a gmail page where to feild is already filled so that people can mail me for support or for supporting my work. Pls see the code below if necessary

#Module import

from tkinter import *
import webbrowser as wb
root = Tk()
root.title("Calculator by Rajdeep !!")
root.geometry('450x300')
font = ('Brush script', 16, 'bold')

#Menubar
def Upgrade():
    wb.open("https:/google.com") 

menubar = Menu(root)  
menubar.add_command(label="Upgrade", command=Upgrade) 
menubar.add_command(label="Become a Patron")
root.config(menu=menubar)

mainloop()
  • 1
    You have to use some web automation library like `selenium`. – Delrius Euphoria Jun 16 '21 at 07:35
  • 2
    why would you force me to use gmail.com? the normal way to do this is to provide a prepopulated `mailto://....` a href link that will be interpreted by the client and opened with designated mail application ... – Patrick Artner Jun 16 '21 at 07:42
  • [https://en.wikipedia.org/wiki/Mailto](https://en.wikipedia.org/wiki/Mailto) – Patrick Artner Jun 16 '21 at 07:44
  • I don't use `gmail` but other mail service and I don't use web browser but program `Thunderbird` for mails so your idea is useless for me. Better use `mailto://....` or add function to copy address to clipboard. – furas Jun 16 '21 at 08:14
  • also per PEP8 function and variable names are `snake_case` so this: `Upgrade` should be `upgrade` – Matiiss Jun 16 '21 at 09:19

1 Answers1

1

GMAIL Only

If you want to do this with gmail only (not mailto as the comments have suggested), the easiest way to do this is to use this answer.

This reads:

https://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&su=SUBJECT&body=BODY&bcc=someone.else@example.com

So if you just wanted to do one for your own code you could do:

wb.open("https://mail.google.com/mail/?view=cm&fs=1&to=me@example.com&su=Bug%20Report") 

The %20 is what a URL uses in place of a space. You could also quite easily add substitution with f-strings to add information such as the date and time when the error occured.

Mailto (as suggested by comments)

People have also suggested using mailto, for example you could write:

wb.open("mailto://me@example.com")

The problem with using mailto as browsers like firefox on both ubuntu and windows open software solutions to sending Emails, whether this be Windows 10 Mail or Thunderbird and users may not have these setup and so would simply open a program. For example, on my system because my Windows 10 is bound to my work account, if I get a mailto link it opens up a work email (which is something I would hesitate to use for a community project)

jimbob88
  • 697
  • 5
  • 20