$textpart->setType('text/plain');
$textpart->setCharset('UTF-8');
$textpart->setContents(_("You have been sent an Ecard. To view the Ecard, you must be able to view text/html messages in your mail reader. If you are viewing this message, then most likely your mail reader does not support viewing text/html messages."));
/* Create the multipart/related part. */
$related = new Horde_Mime_Part();
$related->setType('multipart/related');
/* Create the HTML part. */
$htmlpart = new Horde_Mime_Part();
$htmlpart->setType('text/html');
$htmlpart->setCharset('UTF-8');
/* The image part */
$imgpart = new Horde_Mime_Part();
$imgpart->setType($image->getType('screen'));
$imgpart->setContents($image->raw('screen'));
$img_tag = '<img src="cid:' . $imgpart->setContentID() . '" /><p />';
$comments = $htmlpart->replaceEOL(Horde_Util::getFormData('ecard_comments'));
if (!Horde_Util::getFormData('rtemode')) {
$comments = '<pre>' . htmlspecialchars($comments, ENT_COMPAT, 'UTF-8') . '</pre>';
}
$htmlpart->setContents('<html>' . $img_tag . $comments . '</html>');
$related->setContentTypeParameter('start', $htmlpart->setContentID());
$related->addPart($htmlpart);
$related->addPart($imgpart);
/* Create the multipart/alternative part. */
$alternative = new Horde_Mime_Part();
$alternative->setType('multipart/alternative');
$alternative->addPart($textpart);
$alternative->addPart($related);
/* Add them to the mail message */
$alt = new Horde_Mime_Mail(array('Subject' => _("Ecard - ") . Horde_Util::getFormData('image_desc'), 'To' => $to, 'From' => $from));
$alt->setBasePart($alternative);