Mail Extensions

RSS for tag

Use Mail Extensions for composition, message actions, secure email, and content blocking in the Mail app.

Posts under Mail Extensions tag

18 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

macOS 15.1 MFMailComposeViewController.canSendMail() returns false always
In my Catalyst app I use func setupMailComposer() { // Check if the device can send email guard MFMailComposeViewController.canSendMail() else { print("Mail services are not available") showMailErrorAlert() return } // Create and configure the mail composer let mailComposeVC = MFMailComposeViewController() mailComposeVC.mailComposeDelegate = self // Set the email details mailComposeVC.setToRecipients(["example@example.com"]) mailComposeVC.setSubject("Subject for your email") mailComposeVC.setMessageBody("This is the body of the email.", isHTML: false) // Attach a file (optional) if let filePath = Bundle.main.path(forResource: "example", ofType: "pdf"), let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) { mailComposeVC.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "example.pdf") } // Present the mail composer self.present(mailComposeVC, animated: true, completion: nil) } Since I have updated to macOS 15.1 the canSendMail() function returns false although I have configured Apple Mail (like before in 15.0 where it worked flawlessly).
0
0
38
3d
Correctly using NSAppleScript for Mail.app plugin
Context I'm working on a Mail.app plugin. I would like to disseminate plugin via AppStore. I'm interested in exposing a functionality to user enabling user to choose if plugin should apply to all or selected email account. My intention is to use AppleScript to get a list of available email accounts and expose the list to the end-user via SwiftUI Sourcing account information Apple Script I'm using the following AppleScript tell application "Mail" set accountDict to {} repeat with acc in accounts set accName to name of acc set accEmails to email addresses of acc set accountDict's end to {accName:accEmails} end repeat return accountDict end tell The above generates expected results when executed using Script Editor. Swift Implementation This is still incomplete but shows the overall plan. // // EmailAccounts.swift import Foundation enum EmailScriptError: Error { case scriptExecutionError(String) } struct EmailAccounts { func getAccountNames() -> [String]? { let appleScriptSource = """ tell application "Mail" set accountDict to {} repeat with acc in accounts set accName to name of acc set accEmails to email addresses of acc set accountDict's end to {accName:accEmails} end repeat return accountDict end tell """ var error: NSDictionary? var accountNames: [String] = [] // Create script object, exit if fails guard let scriptObject = NSAppleScript(source: appleScriptSource) else { return nil } // Execute script and store results, nil on error let scriptResult = scriptObject.executeAndReturnError(&error) if error != nil { return nil } // Iterate over results for index in 0...scriptResult.numberOfItems { if let resultEntry = scriptResult.atIndex(index) { if let resultString = resultEntry.stringValue { // Process result handling // accountNames.append(resultString) } } } return accountNames } } Questions Most important one, can I deploy the App on the App Store and use NSAppleScript as shown above? If yes can I use the script in the manner shown above or will I need to store the script in User > Library > Application Scripts location and source it from there. This is outlined in the Scripting from a Sandbox article by Craig Hockenberry, which I cannot link due to being hosted within a not-permitted domain. If yes what entitlements I need to give to the target. I understand that I wouldn't be able to use ScriptingBridge, which feels more robust but wouldn't permit me to deploy the app on the AppStore. My key objective is to programatically identify mail accounts available to Mail.app, if there is a wiser / easier way of doing that I would be more than receptive.
2
0
368
Oct ’24
Can MailKit be used to manage existing messages?
I would like to create a MailKit extension that will allow me to manage my existing messages. I would like to move them around form folder to folder and reqad and update their headers to store some metadata that will be used by the extension. Looking at the documentation for MailKit suggests that I can only implement 4 types of handlers (content blocker, action handler, compose handler and security handler). I can’t see anything in the docs about being able to get a list of messages in the inbox and manipulate them. Am I missing something? I’d love to hear from someone who knows more about this topic before I get into a dead-end rabbit hole. cheers, -tomek
0
0
230
Oct ’24
Adding Mention support in Mail.app using MailKit APIs
Hi, Can I use the MailKit API to add mention support to Mail App. Where I write "@deepak" and my extension suggests me emails starting with the name "deepak" from my contacts. I see there is MEComposeSessionHandler.viewControllerin the mail kit API. But I think, according to the WWDC demo, it can only create UI in the toolbar section of the compose window. Any help will we appreciated here!
1
0
543
Jun ’24
cancel the Apple Developer Enrollment ( Apple support Team help me )
Hello, I would like to cancel Enrollment Membership for the Apple Developer program Enrollment ID 3********9K i didnt pay the fee yet because i want to change it from solo to organization However, I couldn't find how to do this on the developer's website. And i coudn't send request from Support Center Page Also, it always return error in console logs when I sent request support by email method Please help me. Thanks [Edited by Moderator]
2
0
693
Jun ’24
Mail tester, your choice for a complete tool
After spending a lot of time trying to automate my processes, particularly on checking the emails I have on my software, and after talking with people in the field, I looked for a complete solution that could check with great precision in my email lists. I then looked at https://mailtester.ninja/ which in addition to being very complete, offers an API. So my question is whether any of you have other tools, other methods? thank you
1
0
602
May ’24
How to correct wrong iCloud imap server in Mac Mail app?
Mac Mail app always displays iCloud mailbox as an "offline server", while other mailboxes work well. Mac Mail app shows iCloud incoming mail server unrelated to iCloud and to my iCloud ID. The outgoing mail server line is empty. The same iCloud mail account works well on the web and on iPhones but does not work with the Mac Mail app. I have tried resetting the account, rebooting, reloading, etc., and also checked all Help articles and forums, but did not find any guidelines on how to correct incoming and outgoing server addresses for Mac Mail app. MasOS: 14.5 Beta (23F5049f)
0
0
425
Apr ’24
Open custom file extension in my app.
Hello. I have the following question. I have a program that creates files with its own extension and reads them. When I select a file with my extension in the Files app, it automatically opens my app. But if a file with my extension is attached to an email, when I click on my file it shows me a screen with programs to open (actually it shows my program the second time I click on the file, if I click the first time, my program is not listed) . I have a question, is it possible to make the file with my extension attached to the letter immediately open in my program without additional screens or is it not allowed. If possible, then what did I miss, based on the fact that it opens immediately from the Files program. Thank you. P.S. File how it works below: ![] [Image Edited by Moderator to Remove Personal Information]
0
1
654
Apr ’24
MFMailComposeViewController Interactive Dismiss Not Working On iOS 16
I am using MFMailComposeViewController to allow users to share in my app. Now my app is swiftUI so I had to wrap it in UIViewRepresentable. I have tied my mailComposeDelegate for dismissing as well. struct MailComposerView: UIViewControllerRepresentable { @Environment(\.presentationMode) var presentation @Binding var result: Result<MFMailComposeResult, Error>? var mailControllerWrapperBuilder: () -> MFMailComposerControllerWrappable = { MFMailComposeViewController() } let subject: String let body: String class Coordinator: NSObject, MFMailComposeViewControllerDelegate { @Binding var presentation: PresentationMode @Binding var result: Result<MFMailComposeResult, Error>? init(presentation: Binding<PresentationMode>, result: Binding<Result<MFMailComposeResult, Error>?>) { _presentation = presentation _result = result } func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { defer { $presentation.wrappedValue.dismiss() } guard error == nil else { if let error = error { self.result = .failure(error) } else { self.result = .failure(NSError()) } return } self.result = .success(result) } } func makeCoordinator() -> Coordinator { return Coordinator(presentation: presentation, result: $result) } func makeUIViewController(context: UIViewControllerRepresentableContext<MailComposerView>) -> UIViewController { var mailComposer = mailControllerWrapperBuilder() mailComposer.setSubject(subject) mailComposer.setMessageBody(body, isHTML: false) mailComposer.mailComposeDelegate = context.coordinator return mailComposer.getUIViewController() } func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<MailComposerView>) { } } protocol MFMailComposerControllerWrappable { var mailComposeDelegate: MFMailComposeViewControllerDelegate? { get set } var delegate: UINavigationControllerDelegate? { get set } func setSubject(_ subject: String) func setMessageBody(_ body: String, isHTML: Bool) func getUIViewController() -> UIViewController } extension MFMailComposeViewController: MFMailComposerControllerWrappable { func getUIViewController() -> UIViewController { self } } On my main view, which is a swiftui sheet, I present mail composer as a sheet. @State var showMail = false var body: some View { VStack { Button("Mail", action: { showMail = true }) } .sheet(isPresented: $showMail, content: { MailComposerView(result: $viewModel.mailResult, subject: "subject", body: "body") .presentationDetents([.large]) }) } On iOS 17 when swiping down, interactive dismiss is activated and shows user if they want to cancel sending mail. While on iOS16 this behaviour is not observed. I have tried following A custom swiftui view in sheet has interactive dismiss UIViewRespresentable of custom uiview has interactive dismiss Seems like this bug has to do with MFMailComposeViewController itself. Is there a known issue that was fixed in iOS 17? On other apple apps, this behaviour is not observed. One fix that I have on my mind is to present mailcomposer via rootcontroller and not rely on swiftui sheet.
0
0
533
Apr ’24
mailto: URL handling in MacOS Mail.app
Hi, I'm working on a series of scripts and utilities that process logs and generate pre-composed email reports as a consequence, and wanted to use the open "mailto:address?subject=my subject&amp;body=..." to do so from the scripting. to, cc, bcc, subject, and body are all obvious attributes, but what others are handled? Emails are typically sent from a joint mail address, not the user's primary (default) mail account (but one that is also locally provisioned in Mail.app). So I'd like to force the from=address attribute as well. And the messages should be text/plain, not multipart, and the charset of us-ascii. Where can I find the detailed handling on mailto: URL's in MacOS? RFC-6068 is unfortunately a guideline, and doesn't flesh out many requisites. Thanks
0
1
820
Mar ’24
Mail App shows outdated error popup
We have a MailExtension using new Apple MailKit API. The extension returns an error from the SecurityHandler's Encode Method based on certain conditions and If an error is reported during mail send 3/4 times, even after user performed a corrective action and hits send again, the same error is is shown by Mail again for couple more times. The attached sample mail extension project returns an error after hitting send if subject line of the mail is “Show Alert”. If we repeat the error 3/4 times then even after changing the subject line the error is reported once or twice more. it is an Apple issue as per our investigation. After the subject line is changed in the mail, each time security handler’s encodeMessage is called, we return it successfully and no error is returned to Apple. Still the old error pop-up appears. I think this is a gap in sync between the remote process that loads the extension and actual Mail.app process. It takes a bit of time to reflect the status of encoding to Mail.app from the remote helper process. This is a timing issue, depends on how fast you keep bombarding the Send. After making the correction of the erroneous condition (in this sample, the subject line) if you wait for ten seconds and then hit ‘Send’ the issue doesn't happen. which suggests its a timing sync issue at Apple end. Code Sample Anyone else seeing this?
0
0
524
Feb ’24
Proton Mail & Apple Mail.app Mailbox Issues
I'm subscribed to Proton Mail. Their system has my Mail.app client showing nothing in the Inbox while All mail has unread messages. Not sure how this works, and Proton blames it on the client application. With Mail.app closed, I head to the Proton web interface, where it currently shows 9 in Inbox, and 9 in All Mail. So Proton seems to be legit, and Mail.app screws this up somehow. How can I fix this? Cheers
0
0
550
Jan ’24
React Native - iOS - open iMessages Share Extension
I am creating an app where i am opening the direct share extension in app for different apps like instagram, snapchat and whatsapp. It is working fine i know there share extension bundle id and it open perfectly. I also need to open the iMessages share extension in app i have found the bundle id of iMessage share extension it is com.apple.UIKit.activity.Message but when i try to open it got error extension not found. Any one have any idea how i can find the right bundle if for iMessage share extension ? I am using an iOS SPM package LNExtensionExecutor and create a bridge between React Native and this native package.
0
0
826
Jan ’24