Pregunta

I'm using MessageUI framework to compose email in my app. I want set HTML content for the mail body.

So I refered Mugunthkumar's blog and I coded as follow,

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@"Hello from California!"];


// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];  
[picker setBccRecipients:bccRecipients];

// Fill out the email body text    
NSString *pageLink = @"http://mugunthkumar.com/mygreatapp"; // replace it with yours
NSString *iTunesLink = @"http://link-to-mygreatapp"; // replate it with yours
NSString *emailBody =
[NSString stringWithFormat:@"%@\n\n<h3>Sent from <a href = '%@'>MyGreatApp</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", @"title", pageLink, iTunesLink];


[picker setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:picker animated:YES];
[picker release];

When I ran the app and go to the email compose view, I'm getting the following mail body,

enter image description here

I'm using XCode4 and iOS 4.3. I can not see any issue with my code. But I need to insert clickable URLs to my mail body.

please help !!

¿Fue útil?

Solución

If you want to send an HTML-formatted email, it is wrong to escape the HTML tags in the email body. Use </a> instead of &lt;/a&gt; etc.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top