Skip to main content

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")

default_table_style : Apply formatting to Pandas dataframe for use in email

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>
     Email Text Here
     <br>
     {default_table_style(df,index=False)}
     <br>
    </BODY>
</HTML>
"""

multi_table_style : Apply formatting to multiple Pandas dataframes for use in email

def multi_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
    """
Example Call
from outlookutility import multi_table_style
import pandas as pd 
import numpy as np
df = 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>
"""

Metadata

Release files for outlookutility 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for outlookutility 1.4
File Size Uploaded Provenance Actions
outlookutility-1.4.tar.gz 4.8 kB Without provenance Details for outlookutility-1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for outlookutility 1.4
File Interpreter ABI Platform Actions
outlookutility-1.4-py3-none-any.whl Python 3 none any Details for outlookutility-1.4-py3-none-any.whl

Total release size: 13.6 kB

Release files / outlookutility-1.4.tar.gz

Download URL outlookutility-1.4.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cd495376ac5bbfb280f8b6ddfce18e15831b988a9759552986ada0c723948661
BLAKE2b-256 checksum
How to use checksums
cacddf58843db4e73128a0334bcd16a90f6b70ffb0813e349dab228f661d4ccd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / outlookutility-1.4-py3-none-any.whl

Download URL outlookutility-1.4-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b1b710640f00b73d48a3dc2f5e641e16f8416d895decc24d2791344b75f5e87
BLAKE2b-256 checksum
How to use checksums
d07d33aa424e02372a0ef1226d72b14d4e87164c3d46e1789177102f17c345bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Security for outlookutility 1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page