Quellcode durchsuchen

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

tangchao vor 11 Monaten
Ursprung
Commit
7eaca96464

+ 16 - 8
PDF Office/PDF Master/Class/KMLightMember/Tools/Email/KMMailHelper.swift

@@ -56,15 +56,23 @@ import Cocoa
                     make new to recipient at end of to recipients with properties {address:"\(contact)"}
                     tell content
             """
+
+//        let errorDictionary: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
+//        let emailScript = NSAppleScript(source: emailString + "end tell\nactivate\nend tell\nend tell")
+//        let eventDescriptor = emailScript?.executeAndReturnError(errorDictionary)
+//        
+//        if eventDescriptor == nil {
+//            if let url = URL(string: "https://www.pdfreaderpro.com/contact"), !NSWorkspace.shared.open(url) {
+//                NSLog("Failed to open url: \(url)")
+//            }
+//        }
+        let workspace = NSWorkspace.shared
+        let service = NSSharingService(named: NSSharingService.Name.composeEmail)
         
-        let errorDictionary: AutoreleasingUnsafeMutablePointer<NSDictionary?>? = nil
-        let emailScript = NSAppleScript(source: emailString + "end tell\nactivate\nend tell\nend tell")
-        let eventDescriptor = emailScript?.executeAndReturnError(errorDictionary)
+        service?.recipients = [contact]
+        service?.subject = subjects//emailString
+//        service?.messageBody = emailString
         
-        if eventDescriptor == nil {
-            if let url = URL(string: "https://www.pdfreaderpro.com/contact"), !NSWorkspace.shared.open(url) {
-                NSLog("Failed to open url: \(url)")
-            }
-        }
+        service?.perform(withItems: [""])
     }
 }