Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

email attachment

 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to has a email function, but how can i store the attachment path
and then retrieve to let user click to download
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your Private Messages.
 
salvin francis
Bartender
Posts: 1263
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you are using POP3 or IMAP to access the email from the server...

Both the protocols allow you to access a message and all its attachments easily, is your problem reading the message?

provide some more details ....
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. if i store the attachment path
how can i read it and add hyerlink let user download like common email function
 
salvin francis
Bartender
Posts: 1263
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think you can add that as an hyperlink in your application.
mail servers would usually not have a static address for the attachments.

The attachment will be available to your application only when the user has successfully authenticated with the email server and your application has queried for the details of a selected email.

The attachment received will be a part of the Message object.

lets hope this helps you get started, i have left out the attachments part for you...

 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Part.getContent() is your friend when reading anything from an email's contents. Message implements Part.

Run the following recursive call on your Message and see what it returns:
You'll then see for each little part of your email how it is represented. The content could be a String, Multipart, or something else. It's one of those "something else"s you will need.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my code is as below:

MultipartRequest multi = new MultipartRequest(httpRequest , "." , 5*1024*1024 , "big5");

String mailserver = "smtpo.hkbn.net";
String From = multi.getParameter("From");
String to = multi.getParameter("To");
String Subject = multi.getParameter("Subject");
String type = multi.getParameter("Type");
String messageText = multi.getParameter("Message");
String FileName = multi.getFilesystemName("FileName");

boolean sessionDebug = false;

try {


java.util.Properties props = System.getProperties();

props.put("mail.host",mailserver);
props.put("mail.transport.protocol","smtp");


....this is part of my code....

do i insert email attachment as string object into the database.
and treat as string object to select attachment to resultset
how to add link to text,after clicking text ,then download and save as the attachement.???
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15208
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when you post source code.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one important question: what do you want to do exactly? Read an attachment from an existing email, add an attachment to a new email, something else? Because it's not completely clear to me.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic