def run():

    dataDir = "Data/"
    #ExStart: SetMapiProperties
    # Setting MAPI Properties sample
    msg = MapiMessage("*****@*****.**", "*****@*****.**", "This is subject",
                      "This is body")
    msg.set_property(
        MapiProperty(MapiPropertyTag.SENDER_ADDRTYPE, bytes("EX", "utf-8")))

    recipientTo = msg.recipients[0]
    propAddressType = MapiProperty(MapiPropertyTag.RECEIVED_BY_ADDRTYPE,
                                   bytes("MYFAX", "utf-8"))
    recipientTo.set_property(propAddressType)

    faxAddress = "My Fax User@/FN=fax#/VN=voice#/CO=My Company/CI=Local"
    propEmailAddress = MapiProperty(MapiPropertyTag.RECEIVED_BY_EMAIL_ADDRESS,
                                    bytes(faxAddress, "utf-8"))

    recipientTo.set_property(propEmailAddress)

    msg.set_message_flags(MapiMessageFlags.UNSENT | MapiMessageFlags.FROMME)
    msg.set_property(
        MapiProperty(MapiPropertyTag.RTF_IN_SYNC, long_to_mapi_bytes(1)))

    # DateTime property
    modification_date = datetime(2013, 9, 11)
    prop = MapiProperty(MapiPropertyTag.LAST_MODIFICATION_TIME,
                        date_to_mapi_bytes(modification_date))
    msg.set_property(prop)

    msg.save(dataDir + "SetMapiProperties_out.msg")
def run():
    dataDir = "Data/"
    #ExStart: SavingMessageInDraftStatus
    # Create an instance of the MapiMessage class
    outlookMsg = MapiMessage()

    # Set Message Body
    outlookMsg.body = "Message created with MapiMessage in draft mode."

    #Set the Unsent flag
    outlookMsg.set_message_flags(MapiMessageFlags.UNSENT)

    # Save the message (MSG) file
    strMsgFile = "SavingMessageInDraftStatus_out.msg"
    outlookMsg.save(dataDir + strMsgFile)