Chilkat .NET 4 を使用して電子メール メッセージを送信しました。この電子メールは .pfx ファイルで署名され、受信者の .cer ファイルで暗号化されています。これら 2 つのファイルは、Certificates mmc の「Trusted People」フォルダに保存されます。
今、私は Chilkat でこのメールを受信して解読しようとしています。動作しますが、電子メールは復号化されません。私の .pfx ファイルと送信者の .cer ファイルは常に「Trusted People」フォルダにあります。AddPfxSourceData メソッドを使用して独自のプライベート証明書を追加しようとしましたが、TRUE が返されますが、何も起こりません。私が使用したすべての Chilkat オブジェクトの LastErrorText プロパティにエラーはありません。
これは私のコードです(mail.Decryptedは常にFALSEです):
MailMan pop3 = new Chilkat.MailMan();
pop3.UnlockComponent("30-day trial");
pop3.MailHost = "pop.server.net";
pop3.MailPort = 110;
pop3.PopUsername = "my@email.com";
pop3.PopPassword = "mypassword";
bool succes = pop3.AddPfxSourceFile("C:\\my_pfx.pfx, "mypfxpassword");
EmailBundle emailBundle = pop3.CopyMail();
for (int i = 0; i < emailBundle.MessageCount; i++)
{
Email mail = emailBundle.GetEmail(i);
if(mail.ReceivedEncrypted && mail.Decrypted)
Console.WriteLine(mail.Body);
else
Console.WriteLine("Cannot decrypt this mail");
}
何か案は ?
更新: 暗号化された電子メールを送信するために使用したコード:
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("30-day trial");
mailman.SmtpHost = "smtp.server.net";
mailman.SmtpUsername = "sender@mail.com";
mailman.SmtpPassword = "senderpassword";
Chilkat.Email email = new Chilkat.Email();
email.Subject = "This is an encrypted email !";
email.Body = "This is the content of a digitally encrypted mail !";
email.From = "sender@mail.com";
email.AddTo("My Recipient", "my@email.com");
// Certificate of my@email.com
Chilkat.Cert recipientCert = new Chilkat.Cert();
recipientCert.LoadFromFile("C:\\recipient_cert.cer");
email.SetEncryptCert(recipientCert);
email.SendEncrypted = true;
bool success = mailman.SendEmail(email);
if (success)
Console.WriteLine("Mail sent !");