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
Creating and Saving S/MIME Email to .EML File
Demonstrates how to create a digitally signed email and save it to a .eml file. Dim ccs As New ChilkatCreateCS ' Find the certificate that we will use to sign the email. Dim certStore As ChilkatCertStore Set certStore = ccs.OpenCurrentUserStore() Dim cert As ChilkatCert Set cert = certStore.FindCertBySubjectE("matt@chilkatsoft.com") ' We could've loaded the certificate from a DER encoded X.509 .cer file. 'Set cert = New ChilkatCert 'cert.LoadFromFile "matt.cer" ' Create a mailman object. Dim mailman As New ChilkatMailMan2 mailman.UnlockComponent "anything for 30-day trial" ' Create an email object. Dim email As New ChilkatEmail2 ' Assign the cert to the email so that it is used when signing the email. email.SetSigningCert cert email.AddTo "Email Programming Expert", "support@chilkatsoft.com" email.Subject = "This is the subject" email.Body = "Send your example requests to support@chilkatsoft.com" email.From = "matt@chilkatsoft.com" ' Indicate that the email should be sent digitally signed. ' When sending a signed email, the private key is used, so the private key ' associated with the chosen certificate must be installed on the system. email.SendSigned = 1 ' You can create S/MIME with a detached signature (the default), or you can ' set OpaqueSigning = 1 for an opaque signature. mailman.OpaqueSigning = 1 ' The RenderToMime method renders the email according to the property settings. ' In this case, SendSigned = 1, so the rendered MIME will be an S/MIME message. smime = mailman.RenderToMime(email) If Len(smime) = 0 Then MsgBox mailman.LastErrorText End If ' Write this string to a .eml file Open "signedEmail.eml" For Output As #1 Print #1, smime Close #1
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.