VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++DelphiFoxProJavaPerlPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Byte Array

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

Non-Chilkat Links
Text and String Handling

Send Signed Email using PFX File

Demonstrates how to send a signed email using a digital certificate w/ private key stored in a PFX file.

Download Chilkat Email ActiveX for POP3 / SMTP

Download Chilkat IMAP ActiveX

LOCAL loMailman
LOCAL lnSuccess
LOCAL loEmail
LOCAL loCertStore
LOCAL loCert
LOCAL loCert2

*  The mailman object is used for sending and receiving email.
loMailman = CreateObject('Chilkat.MailMan2')

*  Any string argument automatically begins the 30-day trial.

lnSuccess = loMailman.UnlockComponent("30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX("Component unlock failed")
    QUIT
ENDIF

*  Set the SMTP server.
loMailman.SmtpHost = "smtp.mymailserver.com"

*  Create a new email object
loEmail = CreateObject('Chilkat.Email2')

loEmail.Subject = "This email is signed"
loEmail.Body = "This is a digitally signed mail"
loEmail.From = "Chilkat Admin <admin@chilkatsoft.com>"
loEmail.AddTo("Chilkat Support","support@chilkatsoft.com")

*  Indicate that the email should be sent signed.
loEmail.SendSigned = 1

*  Create an instance of a certificate store object, load a PFX file,
*  locate the certificate we need, and use it for signing.
*  (a PFX file may contain more than one certificate.)
loCertStore = CreateObject('Chilkat.CertStore')
*  The 1st argument is the filename, the 2nd arg is the
*  PFX file's password:
lnSuccess = loCertStore.LoadPfxFile("chilkatsoft_secret.pfx","secret")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCertStore.LastErrorText)
    QUIT
ENDIF

loCert = loCertStore.FindCertBySubjectE("admin@chilkatsoft.com")
IF (loCert = NULL ) THEN
    =MESSAGEBOX(loCertStore.LastErrorText)
    QUIT
ENDIF

*  If a PFX file is known to contain a single certificate,
*  you may load it directly into a Chilkat certificate object.
*  This snippet of source code shows how:
loCert2 = CreateObject('Chilkat.Cert')
*  The 1st argument is the filename, the 2nd arg is the
*  PFX file's password:
lnSuccess = loCert2.LoadPfxFile("chilkatsoft_secret.pfx","secret")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCert.LastErrorText)
    QUIT
ENDIF

*  This example will use the cert from the certStore...
loEmail.SetSigningCert(loCert)

*  Send a signed email.
lnSuccess = loMailman.SendEmail(loEmail)
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loMailman.LastErrorText)
ELSE
    *  The LastErrorText property provides information
    *  even when successful.
    =MESSAGEBOX(loMailman.LastErrorText)
    =MESSAGEBOX("Mail Sent!")
ENDIF

Need a specific example? Send a request to support@chilkatsoft.com

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

Mail Component · .NET Email Component · ASP Mail Component · XML Parser