Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ Delphi FoxPro Java Perl Python Ruby SQL Server VBScript
|
Send Already-Signed MIME w/ SendMimeDemonstrates how to use SendMime to send an already-signed MIME message.
LOCAL loMailman LOCAL lnSuccess LOCAL loEmail LOCAL loCertStore LOCAL loCert LOCAL lcSignedMime LOCAL lcFromAddr LOCAL lcRecipients * 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.chilkatsoft.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("chilkat.pfx","myPassword") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loCertStore.LastErrorText) QUIT ENDIF loCert = loCertStore.FindCertBySubject("Chilkat Software, Inc.") IF (loCert = NULL ) THEN =MESSAGEBOX(loCertStore.LastErrorText) QUIT ENDIF * This example will use the cert from the certStore... loEmail.SetSigningCert(loCert) * Render the email to signed-MIME. This is where the private * key is accessed and the signing happens. lcSignedMime = loMailman.RenderToMime(loEmail) * Now send the already-signed MIME: lcFromAddr = "admin@chilkatsoft.com" lcRecipients = "support@chilkatsoft.com, matt@chilkatsoft.com" lnSuccess = loMailman.SendMime(lcFromAddr,lcRecipients,lcSignedMime) 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