Sample code for 30+ languages & platforms
AutoIt

Send Email with hotmail.com, live.com, or outlook.com

See more SMTP Examples

Send email using your Microsoft hotmail.com, live.com, or outlook.com account via the smtp.office365.com SMTP server.

See the Guide for Creating an Application to Send Email from Hotmail.com, Live.com, or Outlook.com

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oMailman = ObjCreate("Chilkat.MailMan")

$oMailman.SmtpHost = "smtp.office365.com"
$oMailman.SmtpPort = 587
$oMailman.StartTLS = True

; This could be your hotmail.com, live.com, or outlook.com account.
$oMailman.SmtpUsername = "yourName@live.com"

; Load the previously saved OAuth2 access token.
$oJson = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJson.LoadFile("qa_data/tokens/hotmail.json")
If ($bSuccess = False) Then
    ConsoleWrite($oJson.LastErrorText & @CRLF)
    Exit
EndIf

$oMailman.OAuth2AccessToken = $oJson.StringOf("access_token")

$oEmail = ObjCreate("Chilkat.Email")

; Note: If you send an email such as this, it can easily go to your Junk or Trash email folders.
$oEmail.Subject = "This is a test"
$oEmail.Body = "This is a test"
; This could be your hotmail.com, live.com, or outlook.com account.
$oEmail.From = "My Hotmail Account <yourName@live.com>"
$bSuccess = $oEmail.AddTo("Joe Example","joe@example.com")

$bSuccess = $oMailman.OpenSmtpConnection()
If ($bSuccess <> True) Then
    ConsoleWrite($oMailman.LastErrorText & @CRLF)
    ConsoleWrite("ConnectFailReason = " & $oMailman.ConnectFailReason & @CRLF)
    Exit
EndIf

$bSuccess = $oMailman.SmtpAuthenticate()
If ($bSuccess <> True) Then
    ConsoleWrite($oMailman.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oMailman.SendEmail($oEmail)
If ($bSuccess <> True) Then
    ConsoleWrite($oMailman.LastErrorText & @CRLF)
    Exit
EndIf

$oMailman.CloseSmtpConnection()

ConsoleWrite("Email Sent." & @CRLF)