![]()  | 
  
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
 
      (AutoIt) Send Email With AttachmentsDemonstrates how to send an email with attachments. 
 ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. ; The mailman object is used for sending (SMTP) and receiving (POP3) email. $oMailman = ObjCreate("Chilkat.MailMan") ; Set the SMTP server. $oMailman.SmtpHost = "smtp.my-tls-mail-server.com" ; Set the SMTP login/password (if required) $oMailman.SmtpUsername = "MY_SMTP_USERNAME" $oMailman.SmtpPassword = "MY_SMTP_PASSWORD" ; Connect to SMTP port 465 using TLS. $oMailman.SmtpSsl = True $oMailman.SmtpPort = 465 ; Create a new email object $oEmail = ObjCreate("Chilkat.Email") $oEmail.Subject = "This is a test" $oEmail.Body = "This is a test" $oEmail.From = "Chilkat Support <support@chilkatsoft.com>" Local $bSuccess = $oEmail.AddTo("Chilkat Admin","admin@chilkatsoft.com") ; To add more recipients, call AddTo, AddCC, or AddBcc once per recipient. ; Add some attachments. ; The AddFileAttachment method returns the value of the content-type it chose for the attachment. Local $sContentType = $oEmail.AddFileAttachment("qa_data/jpg/starfish.jpg") If ($oEmail.LastMethodSuccess <> True) Then ConsoleWrite($oEmail.LastErrorText & @CRLF) Exit EndIf $sContentType = $oEmail.AddFileAttachment("qa_data/pdf/fishing.pdf") If ($oEmail.LastMethodSuccess <> True) Then ConsoleWrite($oEmail.LastErrorText & @CRLF) Exit EndIf ; Call SendEmail to connect to the SMTP server and send. ; The connection (i.e. session) to the SMTP server remains ; open so that subsequent SendEmail calls may use the ; same connection. $bSuccess = $oMailman.SendEmail($oEmail) If ($bSuccess <> True) Then ConsoleWrite($oMailman.LastErrorText & @CRLF) Exit EndIf $bSuccess = $oMailman.CloseSmtpConnection() If ($bSuccess <> True) Then ConsoleWrite("Connection to SMTP server not closed cleanly." & @CRLF) EndIf ConsoleWrite("Mail with attachments sent!" & @CRLF)  | 
  ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.