Closed jstam89 closed 4 years ago
You can use the raw method to use filters. For example:
For getting all unread messages in inbox
$mails = LaravelGmail::message()->raw('in:inbox is:unread')->preload()->all();
For getting all read messages in inbox
$mails = LaravelGmail::message()->raw('in:inbox is:read')->preload()->all();
You can test out the correct filters by using them in the Gmail search box. For more info: Link
It does get my unread emails but I'm getting an empty object as subject and body.
Did you use the preload()
function? Preload fetches all the content of mail as mentioned in the README.
I did as you said. I'm getting a payload with sometimes 60 objects.. I've clicked trough 1 and found a subject somewhere.. but the actual data is not presenting a subject and body.
If you want to reduce the number of mails you can use the take()
function.
Eg:
$mails = LaravelGmail::message()->raw('in:inbox is:unread')->take(5)->preload()->all();
After this, you can run a foreach loop on $mails
to get the content as mentioned here
Eg:
foreach($mails as $mail){
echo $mail->getSubject();
echo $mail->getHtmlBody();
}
I recently started with this and now I would like some help to find out how i can receive the latest receiven emails read and unread. anyone willing to help a poor ol boi?