| Welcome to the Zimbra :: Forums! | |
Welcome, if you would like to post a comment please register.
We also encourage you to explore all things Zimbra with our team and members of the community.
|  | | 
06-30-2008, 04:34 AM
| | Intermediate Member | |
Posts: 22
| | Attach Hi,
someone can help me, I need to understand how attachments work in zimbra.
Can I attach a file automatically to every mail I send?
thanks, greetings Enx | 
06-30-2008, 06:22 AM
| | | what excatly do you want to do ?
from your post i do understand that a draft is enough unless you want to do something else.
Regards | 
06-30-2008, 06:57 AM
| | Intermediate Member | |
Posts: 22
| | When I'm writing a mail, I've an other repository from where take a document to attach to the mail.
So, I want that when I select, via jsp, the document from my personal repository, the document selected is attached automatically at the mail message.
But, I don't know how mail and attachment work.
Thank's | 
06-30-2008, 07:10 AM
| | | well, the mechanism of mail and attachment is very simple it is windows event driven and you can see that when you click on "attach" the popup window open to you so you can choose files from your drives to be attached in , when you choose the file it loads in two different ways : 1- loading in the same page untill the attachment complete and then press ok to the mail page so you are going to press the send button.
2- loading directly to the server and that way uses secure ftp and http method and that means without authentication and you can find that in gmail mail accounts .
relating to your topic perhaps the understanding of how email mechanism done can help you with your purpose or devloping a zimlet that could done your task.
hope i was usefull
regards | 
06-30-2008, 07:19 AM
| | Intermediate Member | |
Posts: 22
| | Thank's, but my question is more low-level.
I've:
var composer = appCtxt.getApp(ZmApp.MAIL).getComposeController();
var callback = new AjxCallback (this,composer._handleResponseSaveDraftListener);
now, i want build up the attachment list, adding this file:
var file ="file:///home/user/tmp/myimg.jpg";
how do it? | 
06-30-2008, 07:41 AM
| | | can you please post the full code
Regards Quote:
var composer = appCtxt.getApp(ZmApp.MAIL).getComposeController();
var callback = new AjxCallback (this,composer._handleResponseSaveDraftListener);
| | 
06-30-2008, 07:47 AM
| | Intermediate Member | |
Posts: 22
| | I must write full code
At this moment, I've the url of the document I want attach at the mail message.
I want write a code to attach the document contained in this url to the mail as attachment,
but I don't know how do it.
I need to know how mail and attachment work, to write the code.
In a pseudo-code I do it:
var attachments = mail.getAttachments();
attachments.add(url);
mail.setAttachments(attachments);
but, I don't find out documentation about mail message
Can you help me? | 
06-30-2008, 07:56 AM
| | | Actually coding that mechanism is much harder than this 
i would like to help you but i need you to share with me - what is the purpose of doing that so we can be on the same line .
i will be waiting your reply , unfortunatly i cant stay on the forum any longer for today cos i have to attend a very long boring meeting  )
will come to you tomorrow.
Regards and best wishes | 
06-30-2008, 08:11 AM
| | Intermediate Member | |
Posts: 22
| | Ok.
So, I started to modify yflickr zimlet, because I want adding a tag from the attachment dialog, to adding a document from the repository of KnowledgeTree.
So, I've a dialog where the user select the document, from KT Repository, to attach at the mail.
At this point, when the document is selected, I must add it to the mail, as an attachment. I've the document's url (but is possible to save the document into local folder, if needed).
To complete this zimlet, I must attach the file at the mail message. I need a method to do it, whatever it is.
Thank's, greetings. | 
07-01-2008, 05:52 AM
| | | try this code hi try this code and let me know what results you got: Quote:
import java.util.Properties;
import java.util.ResourceBundle;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.util.ByteArrayDataSource;
public class Mail {
/**
* @param args
*/
private static String host = null;
private static String from = null;
private static String to = null;
private static String subject = null;
private static String content = null;
private static String filename = "D:\\Users
entry.pdf";
public static void send(String fromAddress,String toAddress,String subject, String mailContent) throws Exception{
send(fromAddress,toAddress,null,subject,mailConten t);
}
public static void send(String fromAddress,String toAddress, String ccAddress,String subject, String mailContent) throws Exception {
ResourceBundle rb = ResourceBundle.getBundle("com.nihon.login.Applicat ion");
MailInfo mail = new MailInfo();
mail.setMailServer(rb.getString("nihon.mail.server "));
if(fromAddress!=null){
mail.setFromAddress(fromAddress);
}else{
mail.setFromAddress(rb.getString("nihon.mail.fromI D"));
}
host = mail.getMailServer();
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(mail.getFromAddress()));
// Set the to address
if(toAddress!=null)
{
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
}
if(ccAddress!=null){
message.addRecipient(Message.RecipientType.CC, new InternetAddress(ccAddress));
}
// Set the subject
message.setSubject(subject);
// Set the content
message.setText(mailContent);
For attachment
//--------------------------------
BodyPart messageBodyPart = new MimeBodyPart();
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
//------------------------------------
// Send message
Transport.send(message);
}
// Method to instantiate once
public static Mail getInstance() {
if (instance == null) {
instance = new Mail();
}
return new Mail();
}
// Construtctor
protected Mail() {
}
private static Mail instance = null;
} | regards
mahmoud | | Thread Tools | Search this Thread | | | | | Display Modes | Linear Mode | | Why Join? Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.  |