|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (Delphi DLL) 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, MailMan, Email, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var mailman: HCkMailMan; json: HCkJsonObject; success: Boolean; email: HCkEmail; begin // 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; | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.