문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top