MailBee.NET Objects 4.0

CertificateStore.DeleteCertificate Method 

Removes the specified certificate from the store.

public bool DeleteCertificate(
   Certificate cert
);

Parameters

cert
The certificate that should be removed from the store.

Return Value

true if the specified certificate was successfully removed; otherwise, false.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException cert is a null reference (Nothing in Visual Basic).
MailBeeCertificateStoreWin32Exception Win32 returned an error on attempt to remove the certificates from the store and ThrowExceptions is true.

Example

This sample removes all certificates having the specified e-mail address from the store.

[C#]
// To use the code below, import MailBee namespace at the top of your code
using MailBee.Security;

// The actual code (put it into a method of your class).
CertificateStore store = new CertificateStore("TestStore", CertStoreType.System, null);
CertificateCollection coll = store.FindCertificates("user@domain.com", CertificateFields.EmailAddress);

foreach (Certificate cert in coll)
{
    store.DeleteCertificate(cert);
}
[Visual Basic]
' To use the code below, import MailBee namespace at the top of your code
Imports MailBee.Security

' The actual code (put it into a method of your class).
Dim store As CertificateStore = New CertificateStore("TestStore", CertStoreType.System, Nothing)
Dim coll As CertificateCollection = store.FindCertificates("user@domain.com", CertificateFields.EmailAddress)

For Each cert As Certificate In coll
    store.DeleteCertificate(cert)
Next

See Also

CertificateStore Class | MailBee.Security Namespace