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
(PureBasic) 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
IncludeFile "CkJsonObject.pb" IncludeFile "CkEmail.pb" IncludeFile "CkMailMan.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. mailman.i = CkMailMan::ckCreate() If mailman.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkMailMan::setCkSmtpHost(mailman, "smtp.office365.com") CkMailMan::setCkSmtpPort(mailman, 587) CkMailMan::setCkStartTLS(mailman, 1) ; This could be your hotmail.com, live.com, or outlook.com account. CkMailMan::setCkSmtpUsername(mailman, "yourName@live.com") ; Load the previously saved OAuth2 access token. json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(json,"qa_data/tokens/hotmail.json") If success = 0 Debug CkJsonObject::ckLastErrorText(json) CkMailMan::ckDispose(mailman) CkJsonObject::ckDispose(json) ProcedureReturn EndIf CkMailMan::setCkOAuth2AccessToken(mailman, CkJsonObject::ckStringOf(json,"access_token")) email.i = CkEmail::ckCreate() If email.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Note: If you send an email such as this, it can easily go to your Junk or Trash email folders. CkEmail::setCkSubject(email, "This is a test") CkEmail::setCkBody(email, "This is a test") ; This could be your hotmail.com, live.com, or outlook.com account. CkEmail::setCkFrom(email, "My Hotmail Account <yourName@live.com>") success = CkEmail::ckAddTo(email,"Joe Example","joe@example.com") success = CkMailMan::ckOpenSmtpConnection(mailman) If success <> 1 Debug CkMailMan::ckLastErrorText(mailman) Debug "ConnectFailReason = " + Str(CkMailMan::ckConnectFailReason(mailman)) CkMailMan::ckDispose(mailman) CkJsonObject::ckDispose(json) CkEmail::ckDispose(email) ProcedureReturn EndIf success = CkMailMan::ckSmtpAuthenticate(mailman) If success <> 1 Debug CkMailMan::ckLastErrorText(mailman) CkMailMan::ckDispose(mailman) CkJsonObject::ckDispose(json) CkEmail::ckDispose(email) ProcedureReturn EndIf success = CkMailMan::ckSendEmail(mailman,email) If success <> 1 Debug CkMailMan::ckLastErrorText(mailman) CkMailMan::ckDispose(mailman) CkJsonObject::ckDispose(json) CkEmail::ckDispose(email) ProcedureReturn EndIf CkMailMan::ckCloseSmtpConnection(mailman) Debug "Email Sent." CkMailMan::ckDispose(mailman) CkJsonObject::ckDispose(json) CkEmail::ckDispose(email) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.