Question:
Hi, We are evaluating Chilkat .NET component to purchase the license. I am trying to create s/mime encrypted message using this example. It looks like "encrypted.txt" file doesn't get encrytped. Could you please let me know if I am doing something wrong? Thank you.
Chilkat.Mime mime = new Chilkat.Mime();
bool success;
//Any string passed to UnlockComponent begins the 30-day trial
//mime.UnlockComponent("30-day trial");
success = mime.UnlockComponent("Anything for 30-day trial");
if (success == false)
{
return;
}
// success = mime.NewMultipartMixed();
mime.SetBodyFromXml("This is a message containing a XML file.");
// Now insert some files:
mime.AppendPartFromFile("sampleXml.xml");
if (success == false)
{
return;
}
mime.SaveMime("unencrypted.txt");
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.
mime.Encrypt(cert);
mime.SaveMime("encrypted.txt");
Chilkat.Mime part2 = null;
part2 = mime.GetPart(1);
byte[] binaryData = null;
binaryData = part2.GetBodyBinary();
There are many things wrong with the code fragment.