Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Using SmtpSendRawCommand to Change PasswordDemonstrates how to use the SmtpSendRawCommand method to change the SMTP user account's password for an SMTP server that supports the non-standard CPWD command. Note: The SmtpSendRawCommand method is not yet released. To get a pre-release, send email to support@chilkatsoft.com.
Dim fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") Set outFile = fso.CreateTextFile("output.txt", True) ' The mailman object is used for sending and receiving email. set mailman = CreateObject("Chilkat.MailMan2") ' Any string argument automatically begins the 30-day trial. success = mailman.UnlockComponent("30-day trial") If (success <> 1) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If ' Set the SMTP server. mailman.SmtpHost = "smtp.chilkatsoft.com" ' Set the SMTP login/password (if required) mailman.SmtpUsername = "myUsername" mailman.SmtpPassword = "myPassword" ' Connect and authenticate: success = mailman.OpenSmtpConnection() If (success <> 1) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If strCharset = "ansi" ' Send the CPWD command and get the response. ' Do not include a trailing CRLF (carriage-return line-feed) in the command string. bEncodeBase64 = False strResponse = mailman.SmtpSendRawCommand("CPWD",strCharset,bEncodeBase64) If (strResponse = vbNullString ) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If ' Expecting a 334 response... If (mailman.LastSmtpStatus <> 334) Then outFile.WriteLine(strResponse) WScript.Quit End If ' Now send the existing login/password, base64-encoded: bEncodeBase64 = True ' Send the existing login: strResponse = mailman.SmtpSendRawCommand("mySmtpLogin",strCharset,bEncodeBase64) If (strResponse = vbNullString ) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If ' Expecting a 334 response... If (mailman.LastSmtpStatus <> 334) Then outFile.WriteLine(strResponse) WScript.Quit End If ' Send the existing password: strResponse = mailman.SmtpSendRawCommand("mySmtpPassword",strCharset,bEncodeBase64) If (strResponse = vbNullString ) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If ' Expecting a 334 response... If (mailman.LastSmtpStatus <> 334) Then outFile.WriteLine(strResponse) WScript.Quit End If ' Send the new password: strResponse = mailman.SmtpSendRawCommand("myNewSmtpPassword",strCharset,bEncodeBase64) If (strResponse = vbNullString ) Then outFile.WriteLine(mailman.LastErrorText) WScript.Quit End If ' Expecting a 250 response... If (mailman.LastSmtpStatus <> 250) Then outFile.WriteLine(strResponse) WScript.Quit End If MsgBox "SMTP password changed!" success = mailman.CloseSmtpConnection() If (success <> 1) Then MsgBox "Connection to SMTP server not closed cleanly." End If outFile.Close |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.