CertificateStoreAddCertificates Method
Adds all the certificates from the specified collection to the store.

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public bool AddCertificates(
	CertificateCollection certs,
	bool overwrite
)

Parameters

certs
Type: MailBee.SecurityCertificateCollection
The collection of the certificates to be added to the store.
overwrite
Type: SystemBoolean
Sets whether the same certificates should be overwritten if they already exist in the store.

Return Value

Type: Boolean
true if the certificates were successfully added to the store; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptioncerts is a null reference (Nothing in Visual Basic).
MailBeeCertificateStoreWin32ExceptionWin32 returned an error on attempt to add any of the certificates to the store and ThrowExceptions is true.
MailBeeCertificateExceptionCryptographicException occurred and ThrowExceptions is true.
Remarks
If this method successfully added at least one certificate from the collection and then failed while adding the next certificate, those certificates which have already been added will remain in the store. In other words, adding multiple certificates is not a single transaction.
Note Note
Starting from .NET Standard 2.0 edition, this method is just a wrapper around AddRange(X509Certificate2Collection) method.
Examples
This sample creates a special store and fills it with the certificates belonging to user@domain.com entity and saves this store to disk.
// 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 newStore = new CertificateStore("", CertStoreType.Memory, null);
CertificateStore myStore = new CertificateStore(CertificateStore.Personal, CertStoreType.System, null);
CertificateCollection coll = myStore.FindCertificates("user@domain.com", CertificateFields.EmailAddress);

newStore.AddCertificates(coll, false);
newStore.SaveToFile(@"C:\Temp\store.sst", CertStoreFileType.Sst, null);
See Also