VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Using SmtpSendRawCommand to Change Password

Demonstrates 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.

Download: Chilkat .NET Assemblies

'  The mailman object is used for sending and receiving email.
Dim mailman As New Chilkat.MailMan()

'  Any string argument automatically begins the 30-day trial.
Dim success As Boolean
success = mailman.UnlockComponent("30-day trial")
If (success <> true) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
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 <> true) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
End If


Dim strCharset As String
strCharset = "ansi"

Dim bEncodeBase64 As Chilkat.bool

'  Send the CPWD command and get the response.
'  Do not include a trailing CRLF (carriage-return line-feed) in the command string.

Dim strResponse As String

bEncodeBase64 = False
strResponse = mailman.SmtpSendRawCommand("CPWD",strCharset,bEncodeBase64)
If (strResponse = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
End If


'  Expecting a 334 response...
If (mailman.LastSmtpStatus <> 334) Then
    TextBox1.Text = TextBox1.Text & strResponse & vbCrLf
    Exit Sub
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
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
End If


'  Expecting a 334 response...
If (mailman.LastSmtpStatus <> 334) Then
    TextBox1.Text = TextBox1.Text & strResponse & vbCrLf
    Exit Sub
End If


'  Send the existing password:
strResponse = mailman.SmtpSendRawCommand("mySmtpPassword",strCharset,bEncodeBase64)
If (strResponse = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
End If


'  Expecting a 334 response...
If (mailman.LastSmtpStatus <> 334) Then
    TextBox1.Text = TextBox1.Text & strResponse & vbCrLf
    Exit Sub
End If


'  Send the new password:
strResponse = mailman.SmtpSendRawCommand("myNewSmtpPassword",strCharset,bEncodeBase64)
If (strResponse = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    Exit Sub
End If


'  Expecting a 250 response...
If (mailman.LastSmtpStatus <> 250) Then
    TextBox1.Text = TextBox1.Text & strResponse & vbCrLf
    Exit Sub
End If


MsgBox("SMTP password changed!")

success = mailman.CloseSmtpConnection()
If (success <> true) Then
    MsgBox("Connection to SMTP server not closed cleanly.")
End If


 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser