messageui

Swift 5 - Email Class Helper / Manager

非 Y 不嫁゛ 提交于 2021-02-10 16:56:31
问题 Edit: Big thanks to Paulw11 for helping me solve this issue. I've added the full code here for easy reuse: Class: import UIKit import MessageUI struct Feedback { let recipients: [String] let subject: String let body: String let footer: String } class FeedbackManager: NSObject, MFMailComposeViewControllerDelegate { private var feedback: Feedback private var completion: ((Result<MFMailComposeResult,Error>)->Void)? override init() { fatalError("Use FeedbackManager(feedback:)") } init?(feedback:

Swift 5 - Email Class Helper / Manager

空扰寡人 提交于 2021-02-10 16:55:59
问题 Edit: Big thanks to Paulw11 for helping me solve this issue. I've added the full code here for easy reuse: Class: import UIKit import MessageUI struct Feedback { let recipients: [String] let subject: String let body: String let footer: String } class FeedbackManager: NSObject, MFMailComposeViewControllerDelegate { private var feedback: Feedback private var completion: ((Result<MFMailComposeResult,Error>)->Void)? override init() { fatalError("Use FeedbackManager(feedback:)") } init?(feedback:

sending email with SwiftUI

陌路散爱 提交于 2021-01-28 08:25:48
问题 I'm trying to implement sending email feature into my mini app. Here's the code I'm using (took it from https://hackingwithswift.com): import Foundation import SwiftUI import MessageUI func sendEmail() { if MFMailComposeViewController.canSendMail() { let mail = MFMailComposeViewController() mail.mailComposeDelegate = self mail.setToRecipients(["you@yoursite.com"]) mail.setMessageBody("<p>You're so awesome!</p>", isHTML: true) present(mail, animated: true) } else { // show failure alert } }

Sending an email from your app with an image attached in Swift

好久不见. 提交于 2020-06-11 04:26:18
问题 I've tried a lot of tutorials on sending emails in your app but none of the ones I've seen show how to send an image with it. I'm recovering an image from .WriteToFile, This image is set to a UIImageView. How should I send an email with my picture? Niall 回答1: You need to add an attachmentData to your mail, encoding your image in an NSData. This is an example that show you how to send an email with your image. I'm suppose that you have a UIViewController where you can put the function sendMail

Sending an email from your app with an image attached in Swift

╄→尐↘猪︶ㄣ 提交于 2020-06-11 04:26:18
问题 I've tried a lot of tutorials on sending emails in your app but none of the ones I've seen show how to send an image with it. I'm recovering an image from .WriteToFile, This image is set to a UIImageView. How should I send an email with my picture? Niall 回答1: You need to add an attachmentData to your mail, encoding your image in an NSData. This is an example that show you how to send an email with your image. I'm suppose that you have a UIViewController where you can put the function sendMail

Sending an email from your app with an image attached in Swift

南楼画角 提交于 2020-06-11 04:26:01
问题 I've tried a lot of tutorials on sending emails in your app but none of the ones I've seen show how to send an image with it. I'm recovering an image from .WriteToFile, This image is set to a UIImageView. How should I send an email with my picture? Niall 回答1: You need to add an attachmentData to your mail, encoding your image in an NSData. This is an example that show you how to send an email with your image. I'm suppose that you have a UIViewController where you can put the function sendMail

Sending an email from swift 3

拜拜、爱过 提交于 2019-12-29 19:06:04
问题 I am trying to set up an app with send email option. I have this code: import Foundation import MessageUI import UIKit class emailClass: UIViewController, MFMailComposeViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() if !MFMailComposeViewController.canSendMail() { print("Mail services are not available") return } sendEmail() } func sendEmail() { let composeVC = MFMailComposeViewController() composeVC.mailComposeDelegate = self // Configure the fields of the interface

Sending an email from swift 3

折月煮酒 提交于 2019-12-29 19:04:07
问题 I am trying to set up an app with send email option. I have this code: import Foundation import MessageUI import UIKit class emailClass: UIViewController, MFMailComposeViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() if !MFMailComposeViewController.canSendMail() { print("Mail services are not available") return } sendEmail() } func sendEmail() { let composeVC = MFMailComposeViewController() composeVC.mailComposeDelegate = self // Configure the fields of the interface

IOS: How to get message body, subject and recepient after message is sent via MFMailComposeController

狂风中的少年 提交于 2019-12-25 11:53:22
问题 I am sending email via following method: -(void) sendEmailOpenControllerWithSubject:(NSString *)subject messsageBody:(NSString *) message { MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:subject]; [controller setMessageBody:message isHTML:NO]; [controller setToRecipients:[[NSArray alloc] initWithObjects:currentProspect.email, nil]]; if (controller) [self presentModalViewController:controller

How to eliminate delay in presentation of MFMessageComposeViewController?

梦想的初衷 提交于 2019-12-23 10:18:04
问题 if([MFMessageComposeViewController canSendText]) { MFMessageComposeViewController *sms_message_vc = [[MFMessageComposeViewController alloc] init]; sms_message_vc.body = text; sms_message_vc.recipients = recipients; sms_message_vc.messageComposeDelegate = self; [self presentModalViewController:sms_message_vc animated:FALSE]; [[UIApplication sharedApplication] setStatusBarHidden:TRUE]; [sms_message_vc release]; } When this executes there's a delay of several seconds before the compose view is