Decrypts the encrypted email by digital certificate.
[Visual Basic]
Public Function Decrypt( _
cert As Certitifcate _
) As Mail
[C#]
public Mail Decrypt(
Certitifcate cert
);
[C++]
public: Mail* Decrypt(
Certitifcate * cert
);
[JScript]
public function Decrypt(
cert : Certitifcate
) : Mail;
Parameters
Return Value
Example
[Visual Basic, C#] The following example demonstrates how to verify signed email and decrypt encrypted email with EAGetMail POP3 & IMAP4 Component. To get the full samples of EAGetMail, please refer to Samples section.
[Visual Basic]
Dim oMail As New Mail("TryIt")
oMail.Load("c:\test.eml, False)
If (oMail.IsEncrypted) Then
Try
' this email is encrypted, we decrypt it by user default certificate.
' you can also use specified certificate like this
' Dim oCert As New Certificate()
' oCert.Load("c:\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET)
' oMail = oMail.Decrypt( oCert )
oMail = oMail.Decrypt(Nothing)
Catch ep As Exception
MessageBox.Show(ep.Message)
End Try
End If
If (oMail.IsSigned) Then
Try
'this email is digital signed.
Dim cert As EAGetMail.Certificate = oMail.VerifySignature()
MessageBox.Show("This email contains a valid digital signature.")
'you can add the certificate to your certificate storage like this
'cert.AddToStore( Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER,"addressbook" );
'then you can use send the encrypted email back to this sender.
Catch ep As Exception
MessageBox.Show(ep.Message)
End Try
End If
[C#]
Mail oMail = new Mail("TryIt");
oMail.Load( "c:\\test.eml", false );
if( oMail.IsEncrypted )
{
try
{
//this email is encrypted, we decrypt it by user default certificate.
// you can also use specified certificate like this
// Certificate oCert = new Certificate();
// oCert.Load("c:\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET)
// oMail = oMail.Decrypt( oCert );
oMail = oMail.Decrypt( null );
}
catch(Exception ep )
{
MessageBox.Show( ep.Message );
}
}
if( oMail.IsSigned )
{
try
{
//this email is digital signed.
EAGetMail.Certificate cert = oMail.VerifySignature();
MessageBox.Show( "This email contains a valid digital signature.");
//you can add the certificate to your certificate storage like this
//cert.AddToStore( Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER,
// "addressbook" );
// then you can use send the encrypted email back to this sender.
}
catch(Exception ep )
{
MessageBox.Show( ep.Message );
}
}
Remarks