0

I am a total Python novice but I am trying to learn by doing. I don't necessarily want a straight answer to this question but would rather hope to get pointed in the right direction.

At my work, people e-mail a template to me, including name, employee number, dates and times. I then need to take this information and copy + paste it into a Webform (forms.office.com) in to the corresponding fields and submit it. Tedious. I am dying.

Can someone help point me in the right direction to get started on this in Python. I have the latest build and use Visual studio code. Thanks in advance for any hints!

Dan Slocum
  • 25
  • 1
  • 4

1 Answers1

1

There are 3 steps to what you want to do:

  • Getting the emails from outlook
  • Parsing the received email to extract the information you want to send to the webform
  • Automatically fill in the webform

For the first step, I'd recommend you look into the pyoutlook library, you can find the official documentation with some quickstart examples here.

In order to parse the email, which I'll assume is an HTML template, BeautifulSoup is your friend! It's a high-level library that will easily let you extract information from html webpages... or emails.

Finally, posting the form. The easiest way would be to use a Microsoft forms API (an interface thta would let you send instructions from python). Unfortunately, theirs doesn't seem to support sending forms, only reading them. So what you could do is use python to control a webbrowser instance and automatically fill in the forms like a human user would do (you can even run headless, invisible browser instances in the background so they won't bother you). Selenium is a good library for that, here's a page with a good beginner-level tutorial on how to use it.

Good luck!

Seon
  • 3,332
  • 8
  • 27