def run(): dataDir = "Data/" #ExStart: SetBodyCompression eml = MailMessage.load(dataDir + "CreatingAndSavingOutlookMessages_out.msg") options = MapiConversionOptions() options.use_body_compression = True ae_mapi = MapiMessage.from_mail_message(eml, options)
def run(): dataDir = "Data/" #ExStart: PreservingEmbeddedMsgFormat eml = MailMessage.load(dataDir + "sample.eml", EmlLoadOptions()) options = MapiConversionOptions.unicode_format options.preserve_embedded_message_format = True # Create an instance of the MapiMessage class and pass MailMessage as argument outlookMsg = MapiMessage.from_mail_message(eml, options)
def run(): dataDir = "Data/" #ExStart: CreatingMSGFilesWithRtfBody eml = MailMessage() eml.is_draft = True # Create an instance of the MapiMessage class and pass MailMessage as argument outlookMsg = MapiMessage.from_mail_message(eml) # Set RTF Body outlookMsg.body_rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Calibri;}}\r\n{\\*\\generator Msftedit 5.41.21.2510;}\\viewkind4\\uc1\\pard\\sa200\\sl276\\slmult1\\lang9\\f0\\fs22 This is RTF Body with this \\b bold \\b0 text.\\par\r\n}\r\n\0" # Save the message (MSG) file strMsgFile = "CreatingMSGFilesWithRtfBody_out.msg" outlookMsg.save(dataDir + strMsgFile);
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: DraftAppointmentRequest #Create Appointment instance attendees = MailAddressCollection() attendees.append("*****@*****.**") app = Appointment("Room 112", dt.datetime(2018, 5, 27, 22, 12, 11), dt.date(2018, 5, 28), "*****@*****.**", attendees); app.summary = "Release Meetting"; app.description = "Discuss for the next release" app.method_type = AppointmentMethodType.PUBLISH message = MailMessage("*****@*****.**", "*****@*****.**", "", "") message.add_alternate_view(app.request_apointment()) msg = MapiMessage.from_mail_message(message) # Save the appointment as draft. msg.save(dataDir + "DraftAppointmentRequest_out.msg")
def run(): dataDir = "Data/" #ExStart: CreateAppointmentFromString ical = """BEGIN:VCALENDAR METHOD:PUBLISH PRODID:-//Aspose Ltd//iCalender Builder (v3.0)//EN VERSION:2.0 BEGIN:VEVENT ATTENDEE;[email protected]:mailto:[email protected] DTSTART:20130220T171439 DTEND:20130220T174439 DTSTAMP:20130220T161439Z END:VEVENT END:VCALENDAR""" sender = "*****@*****.**" recipient = "*****@*****.**" message = MailMessage(sender, recipient, "", "") av = AlternateView.create_alternate_view_from_string(ical, ContentType("text/calendar")) message.alternate_views.append(av) msg = MapiMessage.from_mail_message(message) msg.save(dataDir + "draft_out.msg")
def run(): dataDir = "Data/" #ExStart: DeleteVotingButtonFromMessage message = MapiMessage.from_file("message.msg") FollowUpManager.add_voting_button(message, "Indeed!") message.save(dataDir + "AddVotingButtonToExistingMessage_out.msg") eml = MailMessage("*****@*****.**", "*****@*****.**", "Subject", "Body") eml.is_draft = False msg = MapiMessage.from_mail_message(eml) options = FollowUpOptions() options.voting_buttons = "Yes;No;Maybe;Exactly!" FollowUpManager.set_options(msg, options) msg.save(dataDir + "MapiMsgWithPoll.msg") FollowUpManager.remove_voting_button(msg, "Exactly!") #Deleting a single button OR FollowUpManager.clear_voting_buttons( msg) # Deleting all buttons from a MapiMessage msg.save(dataDir + "MapiMsgWithPoll_out.msg")
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)