Lianja
Lianja
Send Email using office365 SMTP
Demonstrates how to send an email using Office365.Chilkat Lianja Downloads
llSuccess = .F.
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for sending and receiving email.
loMailman = createobject("CkMailMan")
// Set the SMTP server to Office365's SMTP server.
// Note: Please be sure to double-check the SMTP settings
// with your provider or with the official Office365 documentation
// provided by Microsoft. The required settings could change...
loMailman.SmtpHost = "smtp.office365.com"
loMailman.SmtpPort = 587
loMailman.StartTLS = .T.
// Set the SMTP login/password
loMailman.SmtpUsername = "OFFICE365_USERNAME"
loMailman.SmtpPassword = "OFFICE365_PASSWORD"
// Create a new email object
loEmail = createobject("CkEmail")
loEmail.Subject = "This is a test"
loEmail.Body = "This is a test"
loEmail.From = "My Name <my_office365_email@example.com>"
llSuccess = loEmail.AddTo("Chilkat Admin","admin@chilkatsoft.com")
// Call SendEmail to connect to the SMTP server and send.
// The connection (i.e. session) to the SMTP server remains
// open so that subsequent SendEmail calls may use the
// same connection.
llSuccess = loMailman.SendEmail(loEmail)
if (llSuccess <> .T.) then
? loMailman.LastErrorText
release loMailman
release loEmail
return
endif
llSuccess = loMailman.CloseSmtpConnection()
if (llSuccess <> .T.) then
? "Connection to SMTP server not closed cleanly."
endif
? "Mail Sent!"
release loMailman
release loEmail