C# Examples

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

C# Examples

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


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

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.
Chilkat.MailMan mailman = new Chilkat.MailMan();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  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) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

string strCharset;
strCharset = "ansi";

Chilkat.bool bEncodeBase64;

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

string strResponse;

bEncodeBase64 = false;
strResponse = mailman.SmtpSendRawCommand("CPWD",strCharset,bEncodeBase64);
if (strResponse == null ) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  Expecting a 334 response...
if (mailman.LastSmtpStatus != 334) {
    textBox1.Text += strResponse + "\r\n";
    return;
}

//  Now send the existing login/password, base64-encoded:
bEncodeBase64 = true;

//  Send the existing login:
strResponse = mailman.SmtpSendRawCommand("mySmtpLogin",strCharset,bEncodeBase64);
if (strResponse == null ) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  Expecting a 334 response...
if (mailman.LastSmtpStatus != 334) {
    textBox1.Text += strResponse + "\r\n";
    return;
}

//  Send the existing password:
strResponse = mailman.SmtpSendRawCommand("mySmtpPassword",strCharset,bEncodeBase64);
if (strResponse == null ) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  Expecting a 334 response...
if (mailman.LastSmtpStatus != 334) {
    textBox1.Text += strResponse + "\r\n";
    return;
}

//  Send the new password:
strResponse = mailman.SmtpSendRawCommand("myNewSmtpPassword",strCharset,bEncodeBase64);
if (strResponse == null ) {
    textBox1.Text += mailman.LastErrorText + "\r\n";
    return;
}

//  Expecting a 250 response...
if (mailman.LastSmtpStatus != 250) {
    textBox1.Text += strResponse + "\r\n";
    return;
}

MessageBox.Show("SMTP password changed!");

success = mailman.CloseSmtpConnection();
if (success != true) {
    MessageBox.Show("Connection to SMTP server not closed cleanly.");
}


 

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

Email Component · XML Parser