Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi ActiveX) Send Email with hotmail.com, live.com, or outlook.comSee more SMTP ExamplesSend 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
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB; ... procedure TForm1.Button1Click(Sender: TObject); var mailman: TChilkatMailMan; json: TChilkatJsonObject; success: Integer; email: TChilkatEmail; begin // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. mailman := TChilkatMailMan.Create(Self); mailman.SmtpHost := 'smtp.office365.com'; mailman.SmtpPort := 587; mailman.StartTLS := 1; // This could be your hotmail.com, live.com, or outlook.com account. mailman.SmtpUsername := 'yourName@live.com'; // Load the previously saved OAuth2 access token. json := TChilkatJsonObject.Create(Self); success := json.LoadFile('qa_data/tokens/hotmail.json'); if (success = 0) then begin Memo1.Lines.Add(json.LastErrorText); Exit; end; mailman.OAuth2AccessToken := json.StringOf('access_token'); email := TChilkatEmail.Create(Self); // Note: If you send an email such as this, it can easily go to your Junk or Trash email folders. email.Subject := 'This is a test'; email.Body := 'This is a test'; // This could be your hotmail.com, live.com, or outlook.com account. email.From := 'My Hotmail Account <yourName@live.com>'; success := email.AddTo('Joe Example','joe@example.com'); success := mailman.OpenSmtpConnection(); if (success <> 1) then begin Memo1.Lines.Add(mailman.LastErrorText); Memo1.Lines.Add('ConnectFailReason = ' + IntToStr(mailman.ConnectFailReason)); Exit; end; success := mailman.SmtpAuthenticate(); if (success <> 1) then begin Memo1.Lines.Add(mailman.LastErrorText); Exit; end; success := mailman.SendEmail(email.ControlInterface); if (success <> 1) then begin Memo1.Lines.Add(mailman.LastErrorText); Exit; end; mailman.CloseSmtpConnection(); Memo1.Lines.Add('Email Sent.'); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.