Question:
I downloaded the evaluation software and testing the encryption for s/mime. The code fails at the following line. Could you please me know what could be wrong? Thank you.
success = mime.Encrypt(cert);
Here is the LastErrorText message:
ChilkatLog:
SaveMime:
DllDate: Aug 5 2012
UnlockPrefix:30-day trail
Username:
Architecture: Little Endian; 32-bit
Language: .NET 4.0
VerboseLogging: 0
hcCurDate: Fri, 07 Dec 2012
hcExpire: 7/2012
filename: unencrypted.txt
success.
--SaveMime.
--ChilkatLog
Here is my code.
Chilkat.Mime mime = new Chilkat.Mime();
//Any string passed to UnlockComponent begins the 30-day trial
success = mime.UnlockComponent("30-day trial");
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
success = mime.SetBodyFromPlainText("This is a message containing a GIF image file.");
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
success = mime.AppendPartFromFile("dude.gif");
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
success = mime.SaveMime("unencrypted.txt");
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
// Locate a certificate in the Current User Store (in the registry)
// There are many different ways of locating and using certificates
// using Cert, CertStore and CreateCS.
Chilkat.CreateCS ccs = new Chilkat.CreateCS();
Chilkat.CertStore certStore = ccs.OpenCurrentUserStore();
Chilkat.Cert cert = certStore.FindCertForEmail("matt@chilkatsoft.com");
// Use the certificate for encryption.
// This creates an x-pkcs7-mime enveloped message.
success = mime.Encrypt(cert);
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
success = mime.SaveMime("encrypted.txt");
if (success == false)
{
Console.WriteLine(mime.LastErrorText);
return;
}
You've provided the LastErrorText for the "SaveMime" method call, not the "Encrypt" method call. See this: The Basic Concept of LastErrorText