У меня есть этот код, который должен прикреплять HTML-файл к письму, а также отображать содержимое HTML-файла в тело письма. В файле HTML есть ссылка на изображение (read.png ), которое отображается через -вторую строку. Однако он НЕ отображается в теле письма. Что мне нужно сделать, чтобы он отображался?
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self; // set delegate to notify us what's happen'in
[mailer setSubject:[NSString stringWithFormat: @"Site Readings for: %@", gSiteID.globalSiteID]];
// add the image for the HTML
UIImage *toolImage = [UIImage imageNamed:@"reading.png"];
NSData *imageData = UIImagePNGRepresentation(toolImage);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"reading.png"];
// attach file
NSString *file = [[NSBundle mainBundle] pathForResource:@"Surveyor" ofType:@"txt"];
NSData *surveyorTxt= [NSData dataWithContentsOfFile: file];
[mailer addAttachmentData: surveyorTxt mimeType:@"text/html" fileName: @"Surveyor.txt"];
// display the file in the body of the email
NSString *reportBody;
reportBody = [[NSString alloc] initWithData:databuffer encoding:NSASCIIStringEncoding];
[mailer setMessageBody: reportBody isHTML:true]; // indicate the body is html
[self presentModalViewController: mailer animated:TRUE];
Это HTML-код, который должен отображаться:
<html>
<head>
<link rel='stylesheet' type='text/css' href='default.css'/>
</head>
<body>
STA: TBM "J" Elev: 19.76<br>Desc: USGS Test Site
<div>
<table border class="boldtable">
<tr BGCOLOR="ADDAFE">
<th>STA </th>
<th>BS </th>
<th>HI </th>
<th>FS </th>
<th>ELEV </th>
<th>Desc</th>
</tr>
<p><tr>
<td> TBM "J"</td>
<td></td><td></td><td></td>
<td>19.76</td>
<td>USGS Test Site</td>
<p><tr
><td><img src="reading.png" align=center></td><td>3.14</td><td valign="middle">22.90</td>
ОБНОВЛЕНИЕ :Я не думаю, что выразился достаточно ясно... В HTML-коде, отображаемом в исходящем сообщении, должно быть изображение, которое появляется на протяжении всего сообщения. HTML. У меня нет проблем с прикреплением изображения к сообщению, но оно НЕ появляется в HTML, где я этого хочу. Так что явно прикрепить изображение к сообщению не получится... (Я так и думал ).
HTH...