def run(): dataDir = "Data/" #ExStart:ChangeEmailAddress message = MailMessage() message.subject = "Creating Message with Friendly Email Address." # A To address with a friendly name can also be specified like this message.to.append(MailAddress("*****@*****.**", "Kyle Huang")) # Specify Cc and Bcc email address along with a friendly name message.cc.append(MailAddress("*****@*****.**", "Guangzhou Team")) message.bcc.append(MailAddress("*****@*****.**", "Ammad ulHaq ")) message.save(dataDir + "MessageWithFrienlyName_out.eml", SaveOptions.default_eml)
def run(): dataDir = "Data/" #ExStart: CreatingAndSavingOutlookMSG eml = MailMessage() # Set from, to, subject and body properties eml.from_address = "*****@*****.**" eml.to.append("*****@*****.**") eml.subject = "This is test message" eml.body = "This is test body" # Create an instance of the MapiMessage class and pass MailMessage as argument outlookMsg = MapiMessage.from_mail_message(eml) # Save the message (MSG) file strMsgFile = "CreatingAndSavingOutlookMessages_out.msg" outlookMsg.save(dataDir + strMsgFile)
def run(): dataDir = "Data/" #ExStart: AddingMSGAttachments eml = MailMessage() # Set from, to, subject and body properties eml.from_address = "*****@*****.**" eml.to.append("*****@*****.**") eml.subject = "This is test message" eml.body = "This is test body" #Add attachments to MailMessage eml.add_attachment(Attachment(dataDir + "1.jpg")) eml.add_attachment(Attachment(dataDir + "1.doc")) eml.add_attachment(Attachment(dataDir + "1.pdf")) # Create an instance of the MapiMessage class and pass MailMessage as argument outlookMsg = MapiMessage.from_mail_message(eml) # Save the message (MSG) file strMsgFile = "AddingMSGAttachments_out.msg" outlookMsg.save(dataDir + strMsgFile)