【发布时间】:2012-04-28 22:57:03
【问题描述】:
我在我的项目中使用 SkpsmtpMessage 库,一切正常。 问题在于电子邮件正文的布局。我想以漂亮的布局显示它,例如粗体名称,然后想将图像嵌入其中,以便在客户打开电子邮件等时显示。 现在我只是在使用
NSString * bodyMessage = [NSString stringWithFormat:@"Dear %@:\n \nThank you for reserving your holiday with us. Your order is now confirmed -
see below your details including your order reference number and your chosen collection point. ",%@];
它只是演示。 那么我怎样才能像我们在其他电子邮件客户端中那样正确格式化它。
提前谢谢你。
解决方案:
使用
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/html",kSKPSMTPPartContentTypeKey,
body ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
即 text/html 而不是 text/plain。
代码是
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/html",kSKPSMTPPartContentTypeKey,
body ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
[testMsg send];
这里的 body 是包含 html 文本的 NSString...
谢谢。希望其他人可以使用它。
【问题讨论】:
-
非常感谢......我正要浪费我的时间......
标签: ios