Outlook email automation functions
Project description
Outlook Msg Automation functions
display_email: Display draft of email
def display_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;)
"""
Example Call
from outlookutility import display_email
test_html = f"""
<HTML>
<BODY>
Package Testing Email
<br>
</BODY>
</HTML>"""
display_email(
test_html,
"PyPi Test",
"a@abc.com; b@abc.com;",
"c@abc.com;",
)
display_email_with_attachments: Display draft of email with attachments. Can send any number/type of attachments in email.
def display_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.
"""
Example Call
from outlookutility import display_email_with_attachments
test_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",
)
email_without_attachment: Send email without attachments.
def email_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;)
"""
Example Call
from outlookutility import email_without_attachment
test_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;",
)
email_with_attachments: Send email with attachments. Can send any number/type of attachments in email.
def 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.
"""
Example Call
from outlookutility import email_with_attachments
test_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",
)
notify_error: Automated email report for use in exception catch.
def notify_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.
"""
Example Call
from outlookutility import notify_error
import os
def foo():
raise Exception('Error!')
try:
foo()
except Exception as e:
notify_error(f"{os.path.basename(__file__)}", e, "a@email.com")
notify_error: Automated email report for use in exception catch.
def default_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
"""
Example Call
from outlookutility import default_table_style
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(15, 4)), columns=list('ABCD'))
test_message = f"""
<HTML>
<BODY>
{default_table_style(df,index=False)}
<br>
</BODY>
</HTML>
"""
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
outlookutility-1.3.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for outlookutility-1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dbf65ac5961f0108dfd98988c3ac84d85f31c6457c9baac5264553e05b7a444 |
|
MD5 | 3923a7d38af9bb7309c47b2bb6c9396b |
|
BLAKE2b-256 | c1e3d69dcf6036f6e0b74d2746d8b3a52e4db4955e3e2a802c8b839bbcb95699 |