php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

how to get message id, references, in-reply to and other custom headers?

Open laurelBE opened this issue 7 years ago • 1 comments

Hello everyone, I am getting body, subject etc field bu i want message id, references, in-reply to and other custom headers, What should i can do?

Following is my part of code

$mail = $api->getMailItems();
  foreach ($mail as $email) {
	$email = $api->getItem($email->getItemId());
	$email_id=$email->getItemId(); 
	$subject = $email->getSubject();
        $sender = $email->getSender()->getMailbox()->getEmailAddress();
        $body = (string) $email->getBody();

	// Push into object
	array_push($data, array("sender" => $sender, "subject" => $subject, "body" => $body, "buttons" => $buttons)); 
} 

please help me

laurelBE avatar May 21 '18 03:05 laurelBE

Hi @laurelBE,

You must retrieve the detailed informations of the item to obtain these informations.

You can do it simply with the following code:

$mails = $api->getMailItems();

foreach($mails as $mail)
{
    $mail = $api->getItem($mail->getItemId());
    var_dump($mail);
}

So your code is correct and you just need to retrieve these informations by using the getters.

$mail->getXxxXxxXxx();

For example, to get the Internet message id:

$mail->getInternetMessageId();

Or to get the item id:

$mail->getItemId()->getId();

r-hede avatar Jul 03 '18 08:07 r-hede