{"id":23675,"date":"2014-08-21T07:04:52","date_gmt":"2014-08-21T05:04:52","guid":{"rendered":"http:\/\/sviluppo.oimmei.com\/clienti\/oimmeidigitalboutique\/sito\/2014\/08\/21\/using-standard-messageui-send-email\/"},"modified":"2024-11-18T16:38:21","modified_gmt":"2024-11-18T15:38:21","slug":"using-standard-messageui-send-email-2-2","status":"publish","type":"post","link":"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/","title":{"rendered":"Using Standard MessageUI to send an email"},"content":{"rendered":"<p>This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &#8220;Hey can we make this email link clickable?&#8221;. GRRR!<\/p>\n<p>1.First we import the MessagUI as follows<\/p>\n<p>[objc]<br \/>\n#import &lt;MessageUI\/MessageUI.h&gt;<br \/>\n[\/objc]<\/p>\n<p>2.We add the code to our class, so it can implement the following delegate<\/p>\n<p>[objc]MFMailComposeViewControllerDelegate[\/objc]<\/p>\n<ol>\n<li>Let&#8217;s create a class property like this one (give it whatever name you want, we prefer very &#8220;telling&#8221; and explicit names)<\/li>\n<\/ol>\n<p>[objc]@property (strong, nonatomic)<br \/>\nMFMailComposeViewController *mailer;[\/objc]<\/p>\n<ol>\n<li>Finally we implement the method in which to instantiate the<\/li>\n<\/ol>\n<p>[objc]MFMailComposeViewController[\/objc]<\/p>\n<p>and compose the email<\/p>\n<p>[objc]<br \/>\n-(void) sendMailTo: (NSString *) recipient {<br \/>\n&nbsp; &nbsp; self.mailer = [[MFMailComposeViewController alloc] init];<br \/>\nself.mailer.mailComposeDelegate = self;<\/p>\n<p>[self .mailer setSubject:@&#8221;My Fabolous Subject&#8221;];<\/p>\n<p>NSArray *toRecipients = [NSArray arrayWithObjects:recipient, nil];<br \/>\n[self .mailer setToRecipients:toRecipients];<\/p>\n<p>\/* You can uncomment the following code if you have<br \/>\n* images to be inserted as attachments*\/<br \/>\n\/\/ UIImage *myImage = [UIImage imageNamed:@&#8221;myfabolousimage.png&#8221;];<br \/>\n\/\/ NSData *imageData = UIImagePNGRepresentation(myImage);<br \/>\n\/\/ [self .mailer addAttachmentData:imageData \/\/              mimeType:@&#8221;image\/png&#8221; fileName:@&#8221;myfabolousimage.png&#8221;];<\/p>\n<p>NSString *emailBody = @&#8221;&#8221;;<br \/>\n[self .mailer setMessageBody:emailBody isHTML:NO];<\/p>\n<p>[self presentViewController:self.mailer animated:YES completion:nil];<\/p>\n<p>}<br \/>\n[\/objc]<\/p>\n<ol>\n<li>And we certainly can&#8217;t leave the delegate<\/li>\n<\/ol>\n<p>[objc]MFMailComposeViewControllerDelegate[\/objc]<\/p>\n<p>behind, so we&#8217;re going to implement the delegate method as follows, in order to have full control over the mail controller&#8217;s return values, after it has finished its work. Add this method to the class:<\/p>\n<p>[objc]-(void)mailComposeController:<br \/>\n(MFMailComposeViewController *)controller<br \/>\ndidFinishWithResult:(MFMailComposeResult)result<br \/>\nerror:(NSError *)error {<br \/>\nif (error) {<\/p>\n<p>} else {<br \/>\n[self .mailer dismissViewControllerAnimated:YES completion:nil];<br \/>\n}<br \/>\n}<br \/>\n[\/objc]<\/p>\n<ol>\n<li>Enjoy the results! \ud83d\ude42<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &#8220;Hey can we make this email link clickable?&#8221;. GRRR! 1.First we import the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7926,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[91],"tags":[],"class_list":["post-23675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development-en"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &quot;Hey can we make this email link clickable?&quot;. GRRR! 1.First we import the\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Oimmei Team\"\/>\n\t<meta name=\"google-site-verification\" content=\"nrov3ZDmFh2g122GMXaTWPiPrzv3uAspJFs_42s7-6s\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Oimmei Technologies | The Boutique Agency\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Using Standard MessageUI to send an email | Oimmei Technologies\" \/>\n\t\t<meta property=\"og:description\" content=\"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &quot;Hey can we make this email link clickable?&quot;. GRRR! 1.First we import the\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-scaled.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-scaled.png\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-08-21T05:04:52+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-11-18T15:38:21+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Using Standard MessageUI to send an email | Oimmei Technologies\" \/>\n\t\t<meta name=\"twitter:description\" content=\"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &quot;Hey can we make this email link clickable?&quot;. GRRR! 1.First we import the\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-x.png\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Using Standard MessageUI to send an email | Oimmei Technologies","description":"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like \"Hey can we make this email link clickable?\". GRRR! 1.First we import the","canonical_url":"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"nrov3ZDmFh2g122GMXaTWPiPrzv3uAspJFs_42s7-6s","miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"Oimmei Technologies | The Boutique Agency","og:type":"article","og:title":"Using Standard MessageUI to send an email | Oimmei Technologies","og:description":"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &quot;Hey can we make this email link clickable?&quot;. GRRR! 1.First we import the","og:url":"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/","og:image":"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-scaled.png","og:image:secure_url":"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-scaled.png","article:published_time":"2014-08-21T05:04:52+00:00","article:modified_time":"2024-11-18T15:38:21+00:00","twitter:card":"summary","twitter:title":"Using Standard MessageUI to send an email | Oimmei Technologies","twitter:description":"This little code snippet is by far the fastest, and my preferred, way to send an email via the standard API provided by the iOS SDK (7+). It certainly helped me by saving me a lot of time when getting requests like &quot;Hey can we make this email link clickable?&quot;. GRRR! 1.First we import the","twitter:image":"https:\/\/www.oimmei.com\/wp-content\/uploads\/2026\/08\/oimmei-cover-website-26-x.png"},"aioseo_meta_data":{"post_id":"23675","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-03-15 08:49:28","updated":"2025-06-07 19:16:42","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.oimmei.com\/en\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">|<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.oimmei.com\/en\/category\/software-development-en\/\" title=\"Software Development\">Software Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">|<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUsing Standard MessageUI to send an email\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.oimmei.com\/en\/"},{"label":"Software Development","link":"https:\/\/www.oimmei.com\/en\/category\/software-development-en\/"},{"label":"Using Standard MessageUI to send an email","link":"https:\/\/www.oimmei.com\/en\/using-standard-messageui-send-email-2-2\/"}],"_links":{"self":[{"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/posts\/23675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/comments?post=23675"}],"version-history":[{"count":0,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/posts\/23675\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/media\/7926"}],"wp:attachment":[{"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/media?parent=23675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/categories?post=23675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oimmei.com\/en\/wp-json\/wp\/v2\/tags?post=23675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}