Sample code for 30+ languages & platforms
Xbase++

Send Email using smtp-mail.outlook.com with Password Authentication

See more SMTP Examples

Demonstrates how to send an email using smtp-mail.outlook.com using password authentication.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMailman
LOCAL oEmail

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oMailman := CreateObject("Chilkat.MailMan")

oMailman:SmtpHost := "smtp-mail.outlook.com"
oMailman:SmtpPort := 587
oMailman:StartTLS := 1

//  Set the SMTP login/password
oMailman:SmtpUsername := "OFFICE365_USERNAME"
oMailman:SmtpPassword := "OFFICE365_PASSWORD"

//  Create a new email object
oEmail := CreateObject("Chilkat.Email")

oEmail:Subject := "This is a test"
oEmail:Body := "This is a test"
oEmail:From := "My Name <my_office365_email@outlook.com>"
nSuccess := oEmail:AddTo("Chilkat Admin", "admin@chilkatsoft.com")

nSuccess := oMailman:SendEmail(oEmail)
IF (nSuccess != 1)
    ? oMailman:LastErrorText
    oMailman:destroy()
    oEmail:destroy()
    RETURN
ENDIF

? oMailman:SmtpSessionLog

nSuccess := oMailman:CloseSmtpConnection()
IF (nSuccess != 1)
    ? "Connection to SMTP server not closed cleanly."
ENDIF

? "Email Sent!"

oMailman:destroy()
oEmail:destroy()