RUVIDEO
Поделитесь видео 🙏

PYTHON AUTOMATE Email Forward Remove Attachment & Relocate Email

📁 Обучение 👁️ 16 📅 02.12.2023

In a previous video , Python create Daily Planets Sky Map for Epheremis, Email & Automate –(https://www.youtube.com/watch?v=1LgB5kyCA08) I use python to attach created pdf document and attach to email and send to myself and others.
In this video I’m sent a CSV file with meter reading data as an attachment to my Outlook account. I want to detach the CSV attachment to a local folder and then process it and upload it to MySQL database on my server, so that I can use it in a Google Data Studio dashboard.
So first I need to move the email across to my gmail account so that can programmatically access my email to manipulate the emails inside For that I need a Gmail APP password to get around the 2 factor authentication ( see How to Send Emails with Python [New Method 2023]-https://www.youtube.com/watch?v=g_j6ILT-X0k).
I haven't got this setup on my outlook account, so that is why I want to forward to my Gmail account.
I ran across a few issues trying to automate forwarding an email from outlook to gmail.
I initially looked to using Power Automate in Outlook.Live which is onlone browser access to outlook account to detach the attachment to a local folder- there was no free connector that would do this.
So I looked to using Manage Filters in Thunderbird but Thunderbird is a desktop app and needs the computer on to run. As I may or may not have my computer on at a specific time this was not a fully automated process.
So I went back to Outlook Live and it has a RULES tool that allows you to forward emails, so I used that. As Outlook Live is cloud based it runs all the time so that will take care of that automation.
For the Detaching of the Attachment in Gmail I use a python script to download attachment to folder, then rename the file with todays date at the front and then move the Email with attachment to a separate folder so that it wont slow down process of saving attachment for the next day’s email. In python Gmail script you cannot mov a file from Inbox to another folder, you have to copy it to folder and then delete the email in the inbox.
After this I use Pandas to modify the format of the attachment so that its in a suitable format to upload to my database using SQLAlchemy.
One issue I came across was the meter reading dates in the Excel & CSV files was a single number, not come across that format before. In Excel you can reformat the number as a date. The number is like 45091. This is the number of days from 1/1/1900. It is a bit like Unix Time or Epoch time that is calculated in seconds units starting form 1/1/1970. You can reformat seconds into Year/Month/Day/Hour/Min/Sec to get timestamps. For DateTimes, the Excel format is only for Date format.
I came across an anomaly with Eccel conversion to Python datetime module conversion. They gave different dates.
Apparently Excel’s conversion assumes the year 1900 is a leap year, whereas the Datetime module manages leap years correctly. Weirdly you still need to deduct 2 days (not 1) for the python Datetime TimeDelta function to give you the same output as the Excel output.
I’ve given a link to the code files: https://drive.google.com/drive/folders/1bEIZZ3TGu3eroWwuYL9RwsKOxkhySpHs?usp=sharing
I hope this is of help to you, if so, can you please give a thumbs up for the video. Muchas Gracias Please visit my blog for similar topics: https://cr8ive.tk
Kind regards, Max Drake

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «PYTHON AUTOMATE Email Forward Remove Attachment & Relocate Email», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.