Question

I have searched around a bit, but was unable to find an adequate response, so please forgive me if this is already asked on SO.

I would like to do a beautifully formatted/styled email in my MFMailCompseViewController. Is it just a matter of doing a [NSString stringWithFormat...] with a very long HTML form, with the CSS baked in ontop of the head? Something to this effect?

[NSString stringWithFormat:@"<!doctype html> <html> <head> <style type="text/css">
  body {
    color: white;
    background-color: #414042 }
  .p {

    color: #111111;
    text-size: 2em; }
  </style>
  </head>
  <body>
  <h1>This is my beautiful header </h1>
  <p>This is my beautiful paragraph </p>
  </body>
  </html>" ];

Obviously that is a ridiculous example, but is anything like this possible? Maybe even adding fonts and the like?

Thank you!

Was it helpful?

Solution

Yep, that is allowed.

To make sure the HTML is properly recognized, call

- (void)setMessageBody:(NSString*)body isHTML:(BOOL)isHTML when setting the message body with YES as the second argument. Simple as that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top