Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, MailMan, Email, JsonObject;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
mailman: HCkMailMan;
json: HCkJsonObject;
email: HCkEmail;

begin
success := False;

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

mailman := CkMailMan_Create();

CkMailMan_putSmtpHost(mailman,'smtp.office365.com');
CkMailMan_putSmtpPort(mailman,587);
CkMailMan_putStartTLS(mailman,True);

// This could be your hotmail.com, live.com, or outlook.com account.
CkMailMan_putSmtpUsername(mailman,'yourName@live.com');

// Load the previously saved OAuth2 access token.
json := CkJsonObject_Create();
success := CkJsonObject_LoadFile(json,'qa_data/tokens/hotmail.json');
if (success = False) then
  begin
    Memo1.Lines.Add(CkJsonObject__lastErrorText(json));
    Exit;
  end;

CkMailMan_putOAuth2AccessToken(mailman,CkJsonObject__stringOf(json,'access_token'));

email := CkEmail_Create();

// Note: If you send an email such as this, it can easily go to your Junk or Trash email folders.
CkEmail_putSubject(email,'This is a test');
CkEmail_putBody(email,'This is a test');
// This could be your hotmail.com, live.com, or outlook.com account.
CkEmail_putFrom(email,'My Hotmail Account <yourName@live.com>');
success := CkEmail_AddTo(email,'Joe Example','joe@example.com');

success := CkMailMan_OpenSmtpConnection(mailman);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Memo1.Lines.Add('ConnectFailReason = ' + IntToStr(CkMailMan_getConnectFailReason(mailman)));
    Exit;
  end;

success := CkMailMan_SmtpAuthenticate(mailman);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Exit;
  end;

success := CkMailMan_SendEmail(mailman,email);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Exit;
  end;

CkMailMan_CloseSmtpConnection(mailman);

Memo1.Lines.Add('Email Sent.');

CkMailMan_Dispose(mailman);
CkJsonObject_Dispose(json);
CkEmail_Dispose(email);

end;