MFMailComposeViewController 経由で電子メールとして送信する html 文字列を作成します。
2 つの CSS 参照、1 つのローカル CSS と 1 つのサーバー CSS を含めて、オフラインの iPad とオンライン メール クライアントの両方に CSS アクセスを提供します。
NSString *html = @"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> \n";
html = [html stringByAppendingString:@"<html> \n"];
html = [html stringByAppendingString:@"<head> \n"];
html = [html stringByAppendingFormat:@"<link rel=\"stylesheet\" type=\"text/css\" href=\"%@\"> \n", @"styles.css"];
html = [html stringByAppendingFormat:@"<link rel=\"stylesheet\" type=\"text/css\" href=\"%@\"> \n", @"http://www.mydomain.com/styles.css"];
html = [html stringByAppendingString:@"</head> \n"];
オンラインであるため、MFMailComposeViewController は電子メールを正しく表示します (おそらくサーバー css を使用)。オフラインであるため、MFMailComposeViewController には CSS がなく、プレーンな HTML メールのみが表示されます。
私はすでに次のようなローカルcssファイルのパスを決定しようとしました
NSString* cssPath = [[NSBundle mainBundle] pathForResource:@"styles"
ofType:@"css"];
html = [html stringByAppendingFormat:@"<link rel=\"stylesheet\" type=\"text/css\" href=\"%@\"> \n", cssPath];
しかし、何の成功もありません。
ローカル css ファイルを参照するローカル html ファイルは、UIWebView で正しく表示されます。
編集:
HTML メールは、CSS や画像などのバンドル データにアクセスできますか? 私のタグも
background-image: url(image.png);
どちらのパスでも機能しません。