Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read EML attachment inside a message #925

Closed
francescodiperna opened this issue Jun 21, 2022 · 3 comments
Closed

How to read EML attachment inside a message #925

francescodiperna opened this issue Jun 21, 2022 · 3 comments
Labels
question Customer is asking for a clarification, use case or an information. Use it for Issues of type Questi

Comments

@francescodiperna
Copy link

Hi, can anyone give me an example hot to read the content of EML attachment in MIME format?

Kind regards

@ghost ghost added the ToTriage label Jun 21, 2022
@basementmedia2
Copy link

Hi,

i'm also a beginner, but i read emails this way:

require_once __DIR__ . '/vendor/autoload.php'; // your path to autoload.php
// Include the Microsoft Graph classes
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
$tenantId="your tenant id";
$clientId="your client id";
$clientSecret="your secret";

$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';
$token = json_decode($guzzle->post($url, [
    'form_params' => [
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'resource' => 'https://graph.microsoft.com/',
        'grant_type' => 'client_credentials',
    ],
])->getBody()->getContents());

$accessToken = $token->access_token;
$graph = new Graph();
$graph->setAccessToken($accessToken);

// ID of Email must be known
$email = $graph->createRequest("GET", "[email protected]/mailfolders/inbox/messages/ID_of_Email)
->setReturnType(Model\Message::class)
->execute();

// Output response array
print_r($email);

Hope that helps.
As said, i am also still a beginner

Best wishes
Daniel

@francescodiperna
Copy link
Author

Thanks Daniel, but I'm using the endpoint that starts with "/users/" because I'm reading a set of mailboxes of a tenant.
So, I cannot use you code.

Bye

@Ndiritu Ndiritu added question Customer is asking for a clarification, use case or an information. Use it for Issues of type Questi and removed ToTriage labels Oct 6, 2022
@Ndiritu
Copy link
Contributor

Ndiritu commented Jan 31, 2024

Closing this to be tracked under #511

@Ndiritu Ndiritu closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Customer is asking for a clarification, use case or an information. Use it for Issues of type Questi
Projects
Development

No branches or pull requests

3 participants