Skip to content

Commit

Permalink
Merge pull request #32 from just1fi3d/SecureEmail
Browse files Browse the repository at this point in the history
Added Error handling for Emails that cannot be decrypted
  • Loading branch information
Dijji authored Aug 14, 2020
2 parents 6f9c0f6 + 3af6856 commit 81e6333
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,20 +563,29 @@ private void ShowMessage(Message m)
{
try
{
//clear any existing status
ShowStatus(null);

if (m != null)
{
//email is signed and/or encrypted and no body was included
if (m.IsEncryptedOrSigned)
{

Attachment a = m.Attachments[0];
try
{
Attachment a = m.Attachments[0];

//get attachment bytes
var ms = new MemoryStream();
xstFile.SaveAttachment(ms, a);
byte[] attachmentBytes = ms.ToArray();
//get attachment bytes
var ms = new MemoryStream();
xstFile.SaveAttachment(ms, a);
byte[] attachmentBytes = ms.ToArray();

m.ReadSignedOrEncryptedMessage(attachmentBytes);
m.ReadSignedOrEncryptedMessage(attachmentBytes);
}
catch
{
ShowStatus("Message Failed to Decrypt");
}
}
// Can't bind HTML content, so push it into the control, if the message is HTML
if (m.ShowHtml)
Expand Down

0 comments on commit 81e6333

Please sign in to comment.