diff --git a/enzevalos_iphone/MailHandler.swift b/enzevalos_iphone/MailHandler.swift
index 3b9483bf99e5ffa37e39f6547687534fc438f5ca..2746bfa290137348f6077b37b37ee3a4ac0a4444 100644
--- a/enzevalos_iphone/MailHandler.swift
+++ b/enzevalos_iphone/MailHandler.swift
@@ -564,6 +564,7 @@ class MailHandler {
                 }
             }
         }
+        newKeyIds.append(contentsOf: findKeyString(content: body))
         if let header = header, let from = header.from, let date = header.date {
             let mail = DataHandler.handler.createMail(uid, sender: from, receivers: rec, cc: cc, time: date, received: true, subject: header.subject ?? "", body: body, flags: flags, record: record, autocrypt: autocrypt, decryptedData: dec, folderPath: folderPath, secretKey: secretKey, references: references, mailagent: userAgent, messageID: msgID)
             if let m = mail {
@@ -620,22 +621,33 @@ class MailHandler {
         return nil
     }
 
-    private func parsePublicKeys(attachment: MCOAttachment) -> [String] {
+    
+    private func findKeyString(content: String) -> [String] {
         var newKey = [String]()
-        if let content = attachment.decodedString() {
-            if content.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----") {
-                if let start = content.range(of: "-----BEGIN PGP PUBLIC KEY BLOCK-----") {
-                    if let end = content.range(of: "-----END PGP PUBLIC KEY BLOCK-----\n") {
-                        let s = start.lowerBound
-                        let e = end.upperBound
-                        let pk = content[s..<e]
-                        let pgp = SwiftPGP()
-                        if let keyId = try? pgp.importKeys(key: String(pk), pw: nil, isSecretKey: false, autocrypt: false) {
-                            newKey.append(contentsOf: keyId)
-                        }
+        if content.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----") {
+            if let start = content.range(of: "-----BEGIN PGP PUBLIC KEY BLOCK-----") {
+                var end = content.range(of: "-----END PGP PUBLIC KEY BLOCK-----\n")
+                if end == nil {
+                    end = content.range(of: "-----END PGP PUBLIC KEY BLOCK-----")
+                }
+                if let end = end {
+                    let s = start.lowerBound
+                    let e = end.upperBound
+                    let pk = content[s..<e]
+                    let pgp = SwiftPGP()
+                    if let keyId = try? pgp.importKeys(key: String(pk), pw: nil, isSecretKey: false, autocrypt: false) {
+                        newKey.append(contentsOf: keyId)
                     }
                 }
             }
+        }
+        return newKey
+    }
+    
+    private func parsePublicKeys(attachment: MCOAttachment) -> [String] {
+        var newKey = [String]()
+        if let content = attachment.decodedString() {
+            newKey.append(contentsOf: findKeyString(content: content))
         } else if attachment.mimeType == "application/octet-stream", let content = String(data: attachment.data, encoding: String.Encoding.utf8), content.hasPrefix("-----BEGIN PGP PUBLIC KEY BLOCK-----") && (content.hasSuffix("-----END PGP PUBLIC KEY BLOCK-----") || content.hasSuffix("-----END PGP PUBLIC KEY BLOCK-----\n")) {
             let pgp = SwiftPGP()
             if let keyId = try? pgp.importKeys(key: content, pw: nil, isSecretKey: false, autocrypt: false) {