Outlook电子邮件自动化功能

outlookutilit的Python项目详细描述


Outlook消息自动化功能

显示电子邮件:显示电子邮件草稿

defdisplay_email(message:str,subject:str,to_list:str,cc_list:str):"""        :param message: HTML String with Email message contained. See Examples/Email_Strings.py        :param subject: Subject String        :param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        """
示例调用
^{pr2}$

显示带附件的电子邮件:显示带附件的电子邮件草稿。可以通过电子邮件发送任何数量/类型的附件。

defdisplay_email_with_attachments(message:str,subject:str,to_list:str,cc_list:str,*args):"""        :param message: HTML String with Email message contained. See Examples/Email_Body.html.        :param subject: Subject String        :param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param args: Optional attachment arguments, pass as raw file path or stringified file path.        """
示例调用
fromoutlookutilityimportdisplay_email_with_attachmentstest_html=f"""    <HTML>    <BODY>    Package testing email with attachments    <br>    </BODY>    </HTML>"""display_email_with_attachments(test_html,"PyPi Test","a@abc.com; b@abc.com;","c@abc.com;",r"C:\Users\user\test_1.txt",r"C:\Users\user\test_2.txt",)

不带附件的电子邮件:发送不带附件的电子邮件。

defemail_without_attachment(message:str,subject:str,to_list:str,cc_list:str):"""        :param message: HTML String with Email message contained. See Examples/Email_Strings.py        :param subject: Subject String        :param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        """
示例调用
fromoutlookutilityimportemail_without_attachmenttest_html=f"""    <HTML>    <BODY>    Package Testing Email    <br>    </BODY>    </HTML>"""email_without_attachment(test_html,"PyPi Test","a@abc.com; b@abc.com;","c@abc.com;",)

带附件的电子邮件:发送带附件的电子邮件。可以通过电子邮件发送任何数量/类型的附件。

defemail_with_attachments(message:str,subject:str,to_list:str,cc_list:str,*args):"""        :param message: HTML String with Email message contained. See Examples/Email_Body.html.        :param subject: Subject String        :param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)        :param args: Optional attachment arguments, pass as raw file path or stringified file path.        """
示例调用
fromoutlookutilityimportemail_with_attachmentstest_html=f"""    <HTML>    <BODY>    Package testing email with attachments    <br>    </BODY>    </HTML>"""email_with_attachments(test_html,"PyPi Test","a@abc.com; b@abc.com;","c@abc.com;",r"C:\Users\user\test_1.txt",r"C:\Users\user\test_2.txt",)

通知\错误:自动电子邮件报告,用于异常捕获。

defnotify_error(report_name,error_log,to_list:str):"""    :param to_list: List of emails to receive notification.    :param report_name: Name of automated report.    :param error_log: Raised exception or other error to report.    """
示例调用
fromoutlookutilityimportnotify_errorimportosdeffoo():raiseException('Error!')try:foo()exceptExceptionase:notify_error(f"{os.path.basename(__file__)}",e,"a@email.com")

默认表样式:将格式应用于Pandas dataframe,以便在电子邮件中使用

defdefault_table_style(df,index:False):""" Apply a default clean table style to pandas df.to_html() for use in email strings.    :param index: Determines whether you want index displayed in the HTML. Defaults to False.    :type index: Boolean    :param df: Dataframe to apply the style to.    :type df: Pandas Dataframe    :return: HTML string for insertion in email.    :rtype: string    """
示例调用
fromoutlookutilityimportdefault_table_styleimportpandasaspdimportnumpyasnpdf=pd.DataFrame(np.random.randint(0,100,size=(15,4)),columns=list('ABCD'))test_message=f"""<HTML>    <BODY>     Email Text Here     <br>{default_table_style(df,index=False)}     <br>    </BODY></HTML>"""

多表样式:对多个Pandas数据帧应用格式,以便在电子邮件中使用

defmulti_table_style(df_list,index:False):""" Apply a default clean table style to pandas df.to_html() for use in email strings.    This version returns multiple tables stacked on top of each other with a line break inbetween.    :param index: Determines whether you want index displayed in the HTML. Defaults to False.    :type index: Boolean    :param df_list: List of dataframes to return in html format.    :type df: Pandas Dataframe    :return: HTML string for insertion in email.    :rtype: string    """
示例调用
fromoutlookutilityimportmulti_table_styleimportpandasaspdimportnumpyasnpdf=pd.DataFrame(np.random.randint(0,100,size=(15,4)),columns=list('ABCD'))df_list=[df,df]formatted_tables=multi_table_style(df_list,index=False)test_message=f"""<HTML>    <BODY>     Email Text Here     <br>{formatted_tables}     <br>    </BODY></HTML>"""

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java:字符串。RTL设备语言用标志“+”格式化,数字后加符号   java GAE作为桌面应用程序(Swing)的服务提供商   java将InputStream转换为FileInputStream不适用于Apache POI   java外部Voronoi库“网格”:什么是草图和处理?   重载重写的泛型方法java   java显示组织上设置的错误。springframework。验证。jsp中的错误对象   java一些Spring模型属性没有显示在我的JSP中   java无法编译Guava 23的SimpleTimeLimiter示例   java如何更改JTree中的“根”目录名?   java如何在安卓中对相对布局产生连锁反应?   java错误:org。冬眠例外SQLGrammarException:无法提取结果集,dateAccessed是未知列   如何使用java监听JSON文件更新   由抽象封闭类创建的匿名内部类能否通过反射确定实现类?