Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Attach

  1. #1
    jasonhell is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    22
    Rep Power
    7

    Exclamation 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

  2. #2
    mahmoud is offline Senior Member
    Join Date
    Jun 2008
    Location
    Dubai
    Posts
    53
    Rep Power
    6

    Default

    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

  3. #3
    jasonhell is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    22
    Rep Power
    7

    Default

    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

  4. #4
    mahmoud is offline Senior Member
    Join Date
    Jun 2008
    Location
    Dubai
    Posts
    53
    Rep Power
    6

    Default

    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

  5. #5
    jasonhell is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    22
    Rep Power
    7

    Default

    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?

  6. #6
    mahmoud is offline Senior Member
    Join Date
    Jun 2008
    Location
    Dubai
    Posts
    53
    Rep Power
    6

    Default

    can you please post the full code
    Regards

    var composer = appCtxt.getApp(ZmApp.MAIL).getComposeController();
    var callback = new AjxCallback (this,composer._handleResponseSaveDraftListener);

  7. #7
    jasonhell is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    22
    Rep Power
    7

    Default

    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?

  8. #8
    mahmoud is offline Senior Member
    Join Date
    Jun 2008
    Location
    Dubai
    Posts
    53
    Rep Power
    6

    Default

    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

  9. #9
    jasonhell is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    22
    Rep Power
    7

    Default

    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.

  10. #10
    mahmoud is offline Senior Member
    Join Date
    Jun 2008
    Location
    Dubai
    Posts
    53
    Rep Power
    6

    Default try this code

    hi try this code and let me know what results you got:

    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

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Attach a file via SOAP API
    By mannes in forum Developers
    Replies: 2
    Last Post: 10-20-2009, 01:31 PM
  2. How to attach an image to a signature
    By kaouki in forum Users
    Replies: 18
    Last Post: 10-19-2009, 12:55 PM
  3. Attach contacts to email?
    By Guest6400 in forum Users
    Replies: 2
    Last Post: 01-31-2008, 12:15 PM
  4. Attach View
    By rajan in forum Administrators
    Replies: 5
    Last Post: 04-24-2007, 02:37 PM
  5. Calendar appointment attach gone ?
    By sperkins in forum Administrators
    Replies: 3
    Last Post: 12-11-2006, 04:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •