<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[solved] Qt 5.4: Send E-Mai with attachment on iOS]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">like on Android i now want to implement native iOS code to send an e-mail with a file attached.</p>
<p dir="auto">What i tried is the following:</p>
<p dir="auto">Create an objective c interface:</p>
<p dir="auto">@<br />
@interface Mailer : UIViewController &lt;MFMailComposeViewControllerDelegate&gt;<br />
{</p>
<p dir="auto">}</p>
<ul>
<li>(void) dealloc;</li>
<li>(void) sendMailWithAttachment: (NSString*) filename inView: (UIView*) uiview;</li>
<li>(void) mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error;</li>
</ul>
<p dir="auto">@end</p>
<ul>
<li>
<p dir="auto">(void) sendMailWithAttachment: (NSString*) filename inView: (UIView*) uiview;<br />
{<br />
NSLog(@"Mailer:sendMailWithAttachment: create MFMailComposeViewController");</p>
<p dir="auto">//  [view addSubview: self];</p>
<p dir="auto">MFMailComposeViewController *picker = &lsqb;&lsqb;MFMailComposeViewController alloc] init];<br />
picker.mailComposeDelegate = self;<br />
[picker setSubject:@"Check out this image!"];</p>
<p dir="auto">// Fill out the email body text<br />
NSString *emailBody = @"My cool image is attached";<br />
[picker setMessageBody:emailBody isHTML:NO];</p>
<p dir="auto">[self presentModalViewController:picker animated:YES];</p>
<p dir="auto">[picker release];</p>
</li>
</ul>
<p dir="auto">}</p>
<p dir="auto">@</p>
<p dir="auto">The code gets called but i get the error:<br />
@<br />
Warning: Attempt to present &lt;MFMailComposeViewController: 0x7ef9e7e0&gt; on &lt;Mailer: 0x7ef91720&gt; whose view is not in the window hierarchy!<br />
@</p>
<p dir="auto">Any ideas how to solve this issue?</p>
<p dir="auto">Or maybe there is an easier way on iOS to send a mail with attachment?</p>
<p dir="auto">Greetings<br />
Nando</p>
]]></description><link>https://forum.qt.io/topic/47963/solved-qt-5-4-send-e-mai-with-attachment-on-ios</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Nov 2026 06:28:09 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/47963.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Nov 2014 17:46:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] Qt 5.4: Send E-Mai with attachment on iOS on Tue, 10 Feb 2015 10:05:06 GMT]]></title><description><![CDATA[<p dir="auto">Yes,<br />
this is my didFinishWithResult method:</p>
<p dir="auto">@- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error<br />
{<br />
// Notifies users about errors associated with the interface<br />
switch (result)<br />
{<br />
case MFMailComposeResultCancelled:<br />
NSLog(@"Result: canceled");<br />
break;<br />
case MFMailComposeResultSaved:<br />
NSLog(@"Result: saved");<br />
break;<br />
case MFMailComposeResultSent:<br />
NSLog(@"Result: sent");<br />
break;<br />
case MFMailComposeResultFailed:<br />
NSLog(@"Result: failed");<br />
break;<br />
default:<br />
NSLog(@"Result: not sent");<br />
break;<br />
}</p>
<pre><code>[self dismissViewControllerAnimated:YES completion:NULL];

//&lsqb;&lsqb;UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">Hope it helps...<br />
Greetings<br />
Nando</p>
<p dir="auto">[quote author="lynic" date="1423484455"]How did you manager to close the MFMailComposeViewController (e.g. when "didFinishWithResult" is called)? [/quote]</p>
]]></description><link>https://forum.qt.io/post/251607</link><guid isPermaLink="true">https://forum.qt.io/post/251607</guid><dc:creator><![CDATA[nando76]]></dc:creator><pubDate>Tue, 10 Feb 2015 10:05:06 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Qt 5.4: Send E-Mai with attachment on iOS on Tue, 10 Feb 2015 10:05:06 GMT]]></title><description><![CDATA[<p dir="auto">Yes,<br />
this is my didFinishWithResult method:</p>
<p dir="auto">@- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error<br />
{<br />
// Notifies users about errors associated with the interface<br />
switch (result)<br />
{<br />
case MFMailComposeResultCancelled:<br />
NSLog(@"Result: canceled");<br />
break;<br />
case MFMailComposeResultSaved:<br />
NSLog(@"Result: saved");<br />
break;<br />
case MFMailComposeResultSent:<br />
NSLog(@"Result: sent");<br />
break;<br />
case MFMailComposeResultFailed:<br />
NSLog(@"Result: failed");<br />
break;<br />
default:<br />
NSLog(@"Result: not sent");<br />
break;<br />
}</p>
<pre><code>[self dismissViewControllerAnimated:YES completion:NULL];

//&lsqb;&lsqb;UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">Hope it helps...<br />
Greetings<br />
Nando</p>
<p dir="auto">[quote author="lynic" date="1423484455"]How did you manager to close the MFMailComposeViewController (e.g. when "didFinishWithResult" is called)? [/quote]</p>
]]></description><link>https://forum.qt.io/post/261007</link><guid isPermaLink="true">https://forum.qt.io/post/261007</guid><dc:creator><![CDATA[nando76]]></dc:creator><pubDate>Tue, 10 Feb 2015 10:05:06 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Qt 5.4: Send E-Mai with attachment on iOS on Mon, 09 Feb 2015 12:20:55 GMT]]></title><description><![CDATA[<p dir="auto">How did you manager to close the MFMailComposeViewController (e.g. when "didFinishWithResult" is called)?</p>
]]></description><link>https://forum.qt.io/post/251603</link><guid isPermaLink="true">https://forum.qt.io/post/251603</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 09 Feb 2015 12:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Qt 5.4: Send E-Mai with attachment on iOS on Mon, 09 Feb 2015 12:20:55 GMT]]></title><description><![CDATA[<p dir="auto">How did you manager to close the MFMailComposeViewController (e.g. when "didFinishWithResult" is called)?</p>
]]></description><link>https://forum.qt.io/post/260888</link><guid isPermaLink="true">https://forum.qt.io/post/260888</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 09 Feb 2015 12:20:55 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Qt 5.4: Send E-Mai with attachment on iOS on Sun, 09 Nov 2014 18:04:54 GMT]]></title><description><![CDATA[<p dir="auto">Got it working with this code change:<br />
@<br />
&lsqb;&lsqb;UIApplication sharedApplication].keyWindow.rootViewController presentViewController:picker animated:NO completion:nil];<br />
@</p>
<p dir="auto">Greetings Nando</p>
]]></description><link>https://forum.qt.io/post/250774</link><guid isPermaLink="true">https://forum.qt.io/post/250774</guid><dc:creator><![CDATA[nando76]]></dc:creator><pubDate>Sun, 09 Nov 2014 18:04:54 GMT</pubDate></item></channel></rss>