Comments (4)
The documentation shows you the methods you need to get attachments from an email. Here is some code example assuming you have already retrieved your emails and looping from each to get attachments.
if ($email->hasAttachments()) {
// Email has attachments
$attachments = $email->getAttachments()->map(function ($attachment) {
// Save each attachment to your preferred location
return $attachment->saveAttachmentTo('path/to/downloaded/attachments', 'filename', 'disk');
});
// You now have the paths to the downloaded files in the $attachments variable.
}
The methods availed to you by the package that I have used in the code above are: hasAttachments()
, getAttachments()
, saveAttachmentTo($path, $filename, $disk)
from laravel-gmail.
Okay the one which you share is extremely easy and I gonna replace it with mine one. How I did was
$message = LaravelGmail::message()->get( $gmailID );
$parts=($message->payload->parts);
foreach ( $parts as $part ) {
$body = $part->getBody();
if ( $body->getAttachmentId() ) {
$attachment = ( new Attachment( $gmailID, $part ) );
$attach['attachment'][] = ['fileName'=>$attachment->getFileName(),
'size'=> $attachment->getSize(),
'data'=>$attachment->getData()];
}
}
My Bad :-P
By the way thank you this package is very helpful.
from laravel-gmail.
@jmatembu thanks for the help!
@abhiburk I'm glad that you find it helpful.
from laravel-gmail.
Yes it helped me.
Also I wanted to let you know you can add search function in Message class as their is only in: option available in it. I added it in my code. Hope this helps you.
from laravel-gmail.
Related Issues (20)
- Multi-user Login
- If messages are null in all() method error generated HOT 1
- getHeader case sensitive
- setWatch() not working HOT 3
- Bug in last version v6.0
- Version 6.1 is not published HOT 1
- Destination email must be specified in cc and bcc HOT 3
- Need to specify the cc and bcc every time i need to send an email HOT 5
- production.ERROR: refresh token must be passed in or set as part of setAccessToken {"userId":1,"exception":"[object] (LogicException(code: 0): refresh token must be passed in or set as part of setAccessToken at /home/forge/website/vendor/google/apiclient/src/Client.php:332) HOT 2
- Getting error while replying to email HOT 4
- Send Email BCC not working
- Get signature of the user
- Enable function for application wide access
- I have got issue in php version 8.1 Is it available for PHP version 8.1 or laravel10? HOT 2
- Error 400: redirect_uri_mismatch
- refresh token must be passed in or set as part of setaccesstoken HOT 2
- An address can be an instance of Address or a string ("array" given).
- Not supported for Laravel 10 HOT 3
- Multiple user login not working HOT 3
- Hello HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-gmail.