We can send email by outlook with filling all details by python code. and we can implement send email functionality in our project easily.
First we have to give details like from, to subject and attachment then this all details will be filled in outlook with python code. please see the below code.
First we have to give details like from, to subject and attachment then this all details will be filled in outlook with python code. please see the below code.
import win32com.client from win32com.client import Dispatch, constants
const=win32com.client.constants olMailItem = 0x0 obj = win32com.client.Dispatch("Outlook.Application") newMail = obj.CreateItem(olMailItem) newMail.Subject = "I AM SUBJECT!!" newMail.Body = "I AM IN THE BODY\nSO AM I!!!" newMail.To = "abc@abc.com" attachment1 = r"E:\test\logo.png" newMail.Attachments.Add(Source=attachment1) newMail.display() #newMail.send()
hey,
ReplyDeletehow to i just open the new message window in outklook , so that i can manually enter the recipient name and send manually?
This program is for only sending email with pre defined subject and messages in pgm and send through outlook application. here we are using published api (win32) and we are accessing those api ,sending email through it. It will not open outlook application and u can't provide details manually.
DeleteIf you want to open outlook application or any windows application. please go through "AutoItLibrary" module in python. which will provide the access to control any windows application (like open and close app and click button).
Is there any way i can set the account(multiple accounts in outlook) from which mail has to be sent
ReplyDeleteIs there any way i can select the account(Multiple accounts in outlook) from which the mail has to be sent
ReplyDeleteYou can send mail from multiple accounts in outlook. only u have to pass email id in to "newMail.From" if multiple accounts are connected.
DeletenewMail.From does not work
ReplyDeleteIs there way to read the email address from the excel file and send email in python?
ReplyDeleteFirst read excel sheet cell by cell from openpyxl or xlrd third party module and find the email address through regular expression. and send email body whatever you want.
Delete