Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)