Comments (4)
Sorry..wrong typing.
i mean: anyone help??
Original comment by [email protected]
on 27 Mar 2010 at 5:11
from javamail-android.
Here is my code for saving the attachment, but it is IMAP Based, don't know if
it's
different for POP3. I got the original example from a Sun Javamail example.
String folder = getAttachmentFolderForMessage(getMessageUID(msg));
if(msg.isMimeType("multipart/*"))
{ //It's a a multipart so go through the parts and find what looks like the
attachments
Multipart mp = (Multipart)msg.getContent();
int partCount = mp.getCount();
Part curtPart;
String curPartDisposition;
String filename;
File file;
for (int i = 0; i < partCount; i++)
{
curtPart = mp.getBodyPart(1);
curPartDisposition = curtPart.getDisposition();
// many mailers don't include a Content-Disposition
if (curPartDisposition == null || curPartDisposition.equalsIgnoreCase
(Part.ATTACHMENT))
{
filename = curtPart.getFileName();
if (filename == null || filename.length() == 0)
filename = "Attachment" + i;
filename = folder + filename;
try
{
file = new File(filename);
((MimeBodyPart)curtPart).saveFile(file);
Log.d(LogTag,"Saved the attachment "+i+" to the
following filename ["+filename+"].");
}
catch (IOException ex)
{
Log.e(LogTag,"Caught an exception trying to save an
attachment to the filename ["+filename+"].",ex);
throw new IMAPException("Unable to save the attachment
to a file. "+ex.getMessage());
}
}
}
}
Original comment by [email protected]
on 31 Mar 2010 at 1:17
from javamail-android.
Thank you for your response..
but the statement: Multipart mp = (Multipart)msg.getContent();
cannot work on this javamail-android's jar,
it will throws exceptions:
SharedByteArrayInputStream cannot be cast to javax.mail.Multipart
Original comment by [email protected]
on 31 Mar 2010 at 3:00
from javamail-android.
I don't know the full answer but from what I see in the comments and the code
this
is a difference in the mail message you are getting from your mail server. It
might
also have to do with POP3 over IMAP, cause the above code defentily does work
for
me. I would check out the SharedByteArrayInputStream and see if you can read
from
it to get the attachment. Maybe also check the Sun site for javamail and
checkout
the FAQ and or the demo's, they have some good code examples.
Original comment by [email protected]
on 31 Mar 2010 at 3:37
from javamail-android.
Related Issues (20)
- Get Messages via POP HOT 2
- Deadlock Issuing IMAP Command while Idle running. HOT 1
- Not trusted server certificate HOT 4
- Can't authenticate with Hotmail HOT 1
- GPL License
- Getting error while using javamail-android HOT 2
- Can't get old e-mails
- Licensing
- android 3.2?
- Tried to build it: bootstrap/ant-common.xml (No such file or directory) HOT 2
- Unable to build project missing bootstrap HOT 2
- i can not send mail with android 4.0.4 HOT 3
- Can´t get message body
- occurs OutOfMemorry error
- Android Lint error
- Problem regarding Licence
- Gmail detects Suspicious login while using this email client HOT 1
- Patch for /trunk/additionnal/src/org/apache/harmony/awt/internal/nls/MessagesAll.java
- Move project to Github
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 javamail-android.