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
(AutoIt) Send Email to Distribution ListSends the same email to a list of 1000 email addresses in 50 sends where each email has 20 recipients. Note: Chilkat is not intended nor designed for mass emailing. A solution such as this might be used for a corporate emailing to employees, or an emailing to newsletter subscribers.
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oMailman = ObjCreate("Chilkat.MailMan") Local $bSuccess $oMailman.SmtpHost = "smtp.mymailserver.com" $oMailman.SmtpPort = 465 $oMailman.SmtpSsl = True $oMailman.SmtpUsername = "myUsername" $oMailman.SmtpPassword = "myPassword" ; Create a new email object $oEmail = ObjCreate("Chilkat.Email") $oEmail.Subject = "This is a test" $oEmail.Body = "This is a test" $oEmail.From = "Senders Name <sender@example.com>" $oEmail.AddTo("Subscribers","subscribers@example.com") $oBdMime = ObjCreate("Chilkat.BinData") $oMailman.RenderToMimeBd($oEmail,$oBdMime) ; Load a file containing one email address per line. $oDistList = ObjCreate("Chilkat.StringTable") $bSuccess = $oDistList.AppendFromFile(1000,"utf-8","qa_data/distList.txt") If ($bSuccess = False) Then ConsoleWrite($oDistList.LastErrorText & @CRLF) Exit EndIf $oSbRecipients = ObjCreate("Chilkat.StringBuilder") Local $i = 0 Local $iSzDistList = $oDistList.Count Local $iJ = 0 While $i < $iSzDistList ; Build a list of comma-separated recipients. If ($iJ > 0) Then $oSbRecipients.Append(",") EndIf $oSbRecipients.Append($oDistList.StringAt($i)) $i = $i + 1 $iJ = $iJ + 1 ; If we have 20 recipients, or we have the final recipient in the final chunk, then send. If (($iJ = 20) Or ($i = $iSzDistList)) Then $bSuccess = $oMailman.SendMimeBd("sender@example.com",$oSbRecipients.GetAsString(),$oBdMime) If ($bSuccess <> True) Then ConsoleWrite($oMailman.LastErrorText & @CRLF) Exit EndIf $iJ = 0 $oSbRecipients.Clear EndIf Wend $bSuccess = $oMailman.CloseSmtpConnection() If ($bSuccess <> True) Then ConsoleWrite("Connection to SMTP server not closed cleanly." & @CRLF) EndIf ConsoleWrite("Email sent to distirbution list." & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.