views:

46

answers:

1

I'm working with emails from google oauth. This is the format I'm using.

$emailmessage = $storage->getMessage($i); $fromaddress = $storage->getMessage($i)->from;

What format can I use to get only the html body of the email?

I've been looking at this document http://framework.zend.com/apidoc/core/Zend_Mail/Zend_Mail.html, but the formatting seems off. It only has getFrom, which leads me to believe it's an old version.

EDIT: I'm using Zend_Mail_Storage_Imap

A: 

The Zend_Mail_Storage_Imap will not return Zend_Mail but Zend_Mail_Message. So, you'll have to look here for the functions: http://framework.zend.com/apidoc/1.10/Zend_Mail/Zend_Mail_Message.html. As you can see it extends Zend_Mail_Part which has the getContent() method.

The way to get the body part is (in one line):

$content = $storage->getMessage($i)->getContent();
$storage->getBodyHtml($i); ?
Bob Cavezza
I guess `$storage->getMessage($i)` returns an instant of `Zend_Mail`? So it is `$storage->getMessage($i)->getBodyHtml()`
: Call to undefined method Zend_Mail_Storage_Imap::getBodyHtml() in - trying the second one now
Bob Cavezza
Using method 2 - $storage->getMessage($i)->getBodyHtml() causes : Call to undefined method Zend_Mail_Message::getBodyHtml() in
Bob Cavezza
It would have been better to tell before that you're using `Zend_Mail_Storage_Imap` ;)
Sorry - first time using zend - so I really have no idea
Bob Cavezza
No problem, as long as you are descriptive. ;)
Does getContent show only the html? I'll need to parse this after and get the contents between the two html body tags.
Bob Cavezza
Have a look at preg_match for that. php.net/preg_match, and here: http://www.phpro.org/examples/Get-Text-Between-Tags.html