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
(PowerBuilder) 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
integer li_rc oleobject loo_Mailman oleobject loo_Json integer li_Success oleobject loo_Email // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Mailman = create oleobject // Use "Chilkat_9_5_0.MailMan" for versions of Chilkat < 10.0.0 li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan") if li_rc < 0 then destroy loo_Mailman MessageBox("Error","Connecting to COM object failed") return end if loo_Mailman.SmtpHost = "smtp.office365.com" loo_Mailman.SmtpPort = 587 loo_Mailman.StartTLS = 1 // This could be your hotmail.com, live.com, or outlook.com account. loo_Mailman.SmtpUsername = "yourName@live.com" // Load the previously saved OAuth2 access token. loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_Json.LoadFile("qa_data/tokens/hotmail.json") if li_Success = 0 then Write-Debug loo_Json.LastErrorText destroy loo_Mailman destroy loo_Json return end if loo_Mailman.OAuth2AccessToken = loo_Json.StringOf("access_token") loo_Email = create oleobject // Use "Chilkat_9_5_0.Email" for versions of Chilkat < 10.0.0 li_rc = loo_Email.ConnectToNewObject("Chilkat.Email") // Note: If you send an email such as this, it can easily go to your Junk or Trash email folders. loo_Email.Subject = "This is a test" loo_Email.Body = "This is a test" // This could be your hotmail.com, live.com, or outlook.com account. loo_Email.From = "My Hotmail Account <yourName@live.com>" li_Success = loo_Email.AddTo("Joe Example","joe@example.com") li_Success = loo_Mailman.OpenSmtpConnection() if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText Write-Debug "ConnectFailReason = " + string(loo_Mailman.ConnectFailReason) destroy loo_Mailman destroy loo_Json destroy loo_Email return end if li_Success = loo_Mailman.SmtpAuthenticate() if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_Json destroy loo_Email return end if li_Success = loo_Mailman.SendEmail(loo_Email) if li_Success <> 1 then Write-Debug loo_Mailman.LastErrorText destroy loo_Mailman destroy loo_Json destroy loo_Email return end if loo_Mailman.CloseSmtpConnection() Write-Debug "Email Sent." destroy loo_Mailman destroy loo_Json destroy loo_Email |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.