Adds all the certificates from the specified collection to the store.
true if the certificates were successfully added to the store; otherwise, false.
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.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | certs is a null reference (Nothing in Visual Basic). |
| MailBeeCertificateStoreWin32Exception | Win32 returned an error on attempt to add any of the certificates to the store and ThrowExceptions is true. |
This sample creates a special store and fills it with the certificates belonging to user@domain.com entity and saves this store to disk.
[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 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);
[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 newStore As CertificateStore = New CertificateStore("", CertStoreType.Memory, Nothing) Dim myStore As CertificateStore = New CertificateStore(CertificateStore.Personal, CertStoreType.System, Nothing) Dim coll As CertificateCollection = myStore.FindCertificates("user@domain.com", CertificateFields.EmailAddress) newStore.AddCertificates(coll, False) newStore.SaveToFile("C:\Temp\store.sst", CertStoreFileType.Sst, Nothing)
CertificateStore Class | MailBee.Security Namespace | CertificateCollection | AddCertificate