Supposing the usage of Outlook for Windows as application to send emails, and you have some table which you want to send called dataset, and a list of emails called emails:
Initialize the Outlook application, make sure that you have opened it alrealdy before starting the script:
import win32com.client as win32
olApp = win32.Dispatch("Outlook.Application")
olNS = olApp.GetNameSpace("MAPI")
email_sender = "your.email@xxx.xxx"
Creating an email object (empty):
mail_item = olApp.CreateItem(0)
Supposing you want to send a shared email to everyone in copy you can do:
mail_item.To = "; ".join(emails)
Otherwise, if you want to email singularly just loop to email or use multithreading which is more appropriate/fast rather than multiprocessing for this kind of tasks.
mail_item.Subject = "An unusual email."
mail_item.BodyFormat = 1
mail_item._oleobj_.Invoke(*(64209, 0, 8, 0, olNS.Accounts.Item(email_sender)))
Then, initialize your body as a string:
body = ""
Think about a static header which will describe the email and the content of the table and add it to the body:
body += """<td style="line-height:15px;font-family:Arial;mso-line-height-rule:exactly;padding-bottom:5px">{}</td></br>""".format("A Random Header.")
Again, add to the body the pandas table with the .to_html() to parse it correctly as html:
body += """<br><pre>{}</br></pre>""".format(dataset.to_html())
Give the body to the mail_item:
mail_item.HTMLBody = "<html><body>{}</html></body>".format(body)
Send the email:
mail_item.Send()