def run(): #ExStart:RequestReadReceipt # Create an Instance of MailMessage class message = ae.MailMessage() message.from_address = "*****@*****.**" message.to.append(ae.MailAddress("*****@*****.**", "Receiver")) message.subject = "Using MailMessage Features" message.html_body = "<html><body>This is the Html body</body></html>" message.DeliveryNotificationOptions = ae.DeliveryNotificationOptions.ON_SUCCESS message.headers.add("Return-Receipt-To", "*****@*****.**") message.Headers.add("Disposition-Notification-To", "*****@*****.**") # Create an instance of SmtpClient Class and specify your mailing Host server, Username, Password and Port No client = ae.clients.smtp.SmtpClient("smtp.gmail.com", 995, "username", "password") try: # Client.Send will send this message client.send(message) # Display ‘Message Sent’, only if message sent successfully print("Message sent") except: print("Some Error Occured!")
def run(): #ExStart: SendingPlainTextMessage eml = ae.MailMessage() eml.subject = "Message with Plain Text Body" eml.body = "This is plain text body." eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 995, "username", "password") client.security_options = SecurityOptions.AUTO client.send(eml)
def run(): #ExStart: SettingHTMLBody eml = ae.MailMessage() eml.subject = "Message with Html Body" eml.is_body_html = True eml.html_body = "<html><body>This is the <b>HTML</b>body</body></html>" eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 995, "username", "password") client.security_options = SecurityOptions.AUTO client.send(eml)
def run(): #ExStart: SendEmailSynchronously eml = ae.MailMessage() eml.subject = "New MailMessage created with Aspose.Email for Python" eml.html_body = "<b>This line is in bold </b> while this is normal text" eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 2")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 3")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 4")) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 587, "username", "password") client.security_options = SecurityOptions.AUTO client.send(eml)
def run(): dataDir = "Data/"; #ExStart: SpecifyRecipientAddresses eml = ae.MailMessage() eml.subject = "New MailMessage created with Aspose.Email for Python" eml.html_body = "<b>This line is in bold </b> while this is normal text" eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 2")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 3")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 4")) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 587, "username", "password") client.send(eml)
def run(): #ExStart: SendingMeetingRequestsViaEmail eml = ae.MailMessage() eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) #Create Appointment instance app = Appointment("Room 112", dt.datetime(2018, 5, 27, 22, 12, 11), dt.date(2018, 5, 28), eml.from_address, eml.to) app.summary = "Release Meetting" app.description = "Discuss for the next release" eml.add_alternate_view(app.request_apointment()) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 995, "username", "password") client.security_options = SecurityOptions.AUTO client.send(eml)
def run(): #ExStart: MailMessageFeatures message = ae.MailMessage() message.from_address = "*****@*****.**" message.to.append(ae.MailAddress("*****@*****.**", "Receiver")) message.subject = "Using MailMessage Features" # Specify message date message.date = datetime.datetime.now() # Specify message priority message.priority = ae.MailPriority.HIGH # Specify message sensitivity message.Sensitivity = ae.MailSensitivity.NORMAL # Specify options for delivery notifications message.DeliveryNotificationOptions = ae.DeliveryNotificationOptions.ON_SUCCESS
def run(): #ExStart: SetAlternateText eml = ae.MailMessage() eml.subject = "Message with Alternate Text" eml.is_body_html = True eml.html_body = "<html><body>This is the <b>HTML</b>body</body></html>" eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) # Creates AlternateView to view an email message using the content specified in the //string alternate = AlternateView.create_alternate_view_from_string( "Alternate Text") # Adding alternate text eml.alternate_views.append(alternate) #Send using Smtp Client client = SmtpClient("smtp.gmail.com", 995, "username", "password") client.security_options = SecurityOptions.AUTO client.send(eml)
def run(): dataDir = "Data/" #ExStart: CreateNewMailMesssage eml = ae.MailMessage() eml.subject = "New MailMessage created with Aspose.Email for Python" eml.html_body = "<b>This line is in bold </b> while this is normal text" eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 2")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 3")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 4")) #Save generated EML in different formats to disc eml.save(dataDir + "CreateNewMailMessage_out.eml") eml.save(dataDir + "CreateNewMailMessage_out.msg", ae.SaveOptions.default_msg_unicode) eml.save(dataDir + "message_out.msg", ae.SaveOptions.default_msg) eml.save(dataDir + "message_out.mhtml", ae.SaveOptions.default_mhtml) eml.save(dataDir + "message_out.html", ae.SaveOptions.default_html)
def run(): # The path to the File directory. dataDir = "Data/" #ExStart: SetEmailHeaders # Create an instance of MailMessage class eml = ae.MailMessage() # Specify ReplyTo, From, To field, Cc and Bcc Addresses eml.reply_to_list.Add("*****@*****.**") eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 2")) eml.cc.append(ae.MailAddress("*****@*****.**", "Recipient 3")) eml.bcc.append(ae.MailAddress("*****@*****.**", "Recipient 4")) # Specify Date, Message subject, XMailer, Secret Header, Save message to disc eml.subject = "test mail" eml.date = datetime.datetime(2006, 3, 6, 12, 00) eml.xmailer = "Aspose.Email" eml.headers.Add("secret-header", "mystery") eml.save(dataDir + "SetEmailHeaders_out.msg", ae.SaveOptions.default_msg)
def run(): #ExStart: SpecifyCustomHeader # Create an instance of MailMessage class eml = ae.MailMessage() # Specify ReplyTo, From, To field, Cc and Bcc Addresses eml.reply_to_list.Add("*****@*****.**") eml.from_address = "*****@*****.**" eml.to.append(ae.MailAddress("*****@*****.**", "Recipient 1")) eml.subject = "test mail" eml.headers.Add("secret-header", "mystery") client = ae.clients.smtp.SmtpClient("smtp.gmail.com", 995, "username", "password") try: # Client.Send will send this message client.send(eml) # Display ‘Message Sent’, only if message sent successfully print("Message sent") except: print("Some Error Occured!")