public MailModel VerifyEmail(Outlook.MailItem mailItem) { var mail = mailItem.Body ?? mailItem.HTMLBody; if (Regex.IsMatch(mail, PgpSignedHeader) == false) { return null; } var context = new CryptoContext(Passphrase); var crypto = new PgpCrypto(context); try { var valid = crypto.Verify(_encoding.GetBytes(mail)); context = crypto.Context; var signature = new Signature { KeyId = context.SignedByKeyId, UserId = context.SignedByUserId, Valid = valid }; if (mailItem.BodyFormat == Outlook.OlBodyFormat.olFormatHTML) { return new HtmlMailModel { Signature = signature, Body = mailItem.HTMLBody }; } return new PlainMailModel { Signature = signature, Body = mailItem.Body }; } catch (PublicKeyNotFoundException ex) { } catch (Exception ex) { Passphrase = null; WriteErrorData("VerifyEmail", ex); ShowErrorBox(ex.Message); } return null; }