import os\nsubtables_path = r"C:\Users\LOH2HZ\Desktop\2023.6 email sending\SubTables" # \u5b9a\u4e49\u5b50\u8868\u6587\u4ef6\u5939\u7684\u8def\u5f84\n\n# \u904d\u5386 Excel \u6587\u4ef6\u7684\u6bcf\u4e00\u884c\u5e76\u9644\u52a0\u76f8\u5e94\u7684\u5b50\u8868\nfor i, row in df.iterrows(): \n pm_name = row['Project manager']\n pm_email = row['Email address']\n cc = row['CC']\n \n if pd.isna(pm_name) or pd.isna(pm_email):\n print(f'Missing information for row {i}')\n continue\n\n msg = MIMEMultipart() \n msg['Subject'] = 'Open ProNovia E-mail reminder'\n msg['From'] = sender\n msg['To'] = pm_email\n msg['Cc'] = cc\n\n receiver_list = [pm_email] # Create a new list with pm_email as the first element\n if not pd.isna(cc): # Add cc values to the receiver_list if it is not empty\n receiver_list.extend(cc.split(','))\n\n content='''\n Dear PJMs & VS managers,
\n
\n This is a warm E-mail reminder about open ProNovia process of new components in your project.
\n
       You can check your ProNovia status and push relevant associates to fast release components.
\n       (LINK:How to check components are stuck in which department)
\n
       You can issue a CR to discontinue components if they are not needed any more or project cancelled.
\n
\n Let's make our effort together to shorten the components release duration!
\n
Thanks.
\n
PT-BE/ETS1-Hz Team
\n '''\n\n puretext = MIMEText(content,'html','utf-8') # plain html\n msg.attach(puretext)\n\n excel_path = os.path.join(subtables_path, f"{pm_name}.xlsx")\n if os.path.exists(excel_path):\n xlsxpart = MIMEApplication(open(excel_path, 'rb').read())\n xlsxpart.add_header('Content-Disposition', 'attachment', filename=f'{pm_name}.xlsx')\n msg.attach(xlsxpart)\n smtpObj.sendmail(sender, receiver_list, msg.as_string()) # \u53d1\u9001\u90ae\u4ef6\u7ed9\u8be5Project manager\u53caCC\n else:\n print(f'Subtable for {pm_name} not found')\n\n\nsmtpObj.quit() # \u53d1\u9001\u5b8c\u6210\u6240\u6709\u7684\u90ae\u4ef6\u540e\u5173\u95ed\u8fde\u63a5


原文地址: https://www.cveoy.top/t/topic/pqZV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录