Package javax.mail.internet

Examples of javax.mail.internet.MimeMessage


      //not use SMTP Authentication
      session = Session.getDefaultInstance(props, null);
    }
   
    // Building MimeMessage
    MimeMessage mimeMessage = new MimeMessage(session);
    mimeMessage.setSubject(subject);
    mimeMessage.setFrom(new InternetAddress(from));
    mimeMessage.addRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
   
    // -- Create a new message --
    BodyPart msg = new MimeBodyPart();
    msg.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlBody, "text/html; charset=\"utf-8\"")));
   
    Multipart multipart = new MimeMultipart();
   
    BodyPart iCalAttachment = new MimeBodyPart();
    iCalAttachment.setDataHandler(new DataHandler(new javax.mail.util.ByteArrayDataSource(new ByteArrayInputStream(iCalMimeBody), "text/calendar;method=REQUEST;charset=\"UTF-8\"")));

    multipart.addBodyPart(iCalAttachment);
    multipart.addBodyPart(msg);
   
    mimeMessage.setContent(multipart);
   
    // -- Set some other header information --
    //mimeMessage.setHeader("X-Mailer", "XML-Mail");
    //mimeMessage.setSentDate(new Date());
   
View Full Code Here


  public void run() {
    try {
      getLogger().log(Level.FINE, "creating new message.");
      // create the template first.  this is done so the new message
      // opens as a top-level window.
      NewMessageFrame template = new NewMessageFrame(new NewMessageProxy(new NewMessageInfo(new MimeMessage(Pooka.getDefaultSession()))));

      MimeMessage mm = new MimeMessage(Pooka.getDefaultSession());
      if (fAddress != null)
        mm.setRecipients(Message.RecipientType.TO, fAddress);

      NewMessageInfo info = new NewMessageInfo(mm);
      if (fProfile != null)
        info.setDefaultProfile(fProfile);
View Full Code Here

   * editor for it.  If
   */
  public void openWindowAsNew(boolean removeProxy) {
    try {
      // first create the NewMessageProxy from this MessageProxy.
      Message newMessage = new MimeMessage((MimeMessage)getMessageInfo().getMessage());
      NewMessageInfo nmi = new NewMessageInfo(newMessage);
      NewMessageProxy nmp = new NewMessageProxy(nmi);
      nmi.setDefaultProfile(getDefaultProfile());

      final MessageUI nmu = Pooka.getUIFactory().createMessageUI(nmp, getMessageUI());
View Full Code Here

  /**
   * Calls createNewMessage(Message m) with a new MimeMessage object.
   */
  public void createNewMessage() {
    createNewMessage(new MimeMessage(Pooka.getMainPanel().getSession()));
  }
View Full Code Here

  public void cacheMessage (MessageInfo info, int cacheStatus) throws MessagingException {
    if (status == CONNECTED) {
      Message m = info.getMessage();
      if (m instanceof CachingMimeMessage) {
        long uid = ((CachingMimeMessage)m).getUID();
        MimeMessage realMessage = getRealMessageById(uid);
        getCache().cacheMessage(realMessage, uid, uidValidity, cacheStatus);
      } else if (m instanceof MimeMessage) {
        long uid = getUID(m);
        getCache().cacheMessage((MimeMessage)m, uid, uidValidity, cacheStatus);
      } else {
View Full Code Here

   * Gets the raw RFC 822 message.
   */
  public String getRawText() throws MessagingException {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      MimeMessage mm = (MimeMessage) getMessage();
      mm.writeTo(baos);
      return baos.toString();
    } catch (IOException ioe) {
      MessagingException returnValue = new MessagingException("Error reading Message Stream", ioe);
      throw returnValue;
    }
View Full Code Here

  /**
   * Bounces this message to another user.
   */
  public void bounceMessage(Address[] recipientList) throws javax.mail.MessagingException {

    MimeMessage mm = (MimeMessage)getMessage();
    MimeMessage mmClone = new MimeMessage(mm);

    NewMessageInfo nmi = new NewMessageInfo(mmClone);
    net.suberic.pooka.gui.NewMessageProxy nmp = new net.suberic.pooka.gui.NewMessageProxy(nmi);
    java.util.HashMap messageMap = new java.util.HashMap();
    messageMap.put(mmClone, recipientList);
View Full Code Here

   * This populates a message which is a reply to the current
   * message.
   */
  public NewMessageInfo populateReply(boolean replyAll, boolean withAttachments)
    throws MessagingException, OperationCancelledException  {
    MimeMessage newMsg = (MimeMessage) getMessage().reply(replyAll);

    MimeMessage mMsg = (MimeMessage) getMessage();

    String textPart = getTextPart(false, false, getMaxMessageDisplayLength(), getTruncationMessage());
    if (textPart == null) {
      textPart = "";
    }
View Full Code Here

   * This populates a new message which is a forwarding of the
   * current message.
   */
  public NewMessageInfo populateForward(boolean withAttachments, int method)
    throws MessagingException, OperationCancelledException  {
    MimeMessage mMsg = (MimeMessage) getMessage();
    MimeMessage newMsg = new MimeMessage(Pooka.getDefaultSession());

    String parsedText = "";

    if (method == FORWARD_QUOTED) {
      String textPart = getTextPart(false, false, getMaxMessageDisplayLength(), getTruncationMessage());

      UserProfile up = getDefaultProfile();
      if (up == null) {
        up = Pooka.getPookaManager().getUserProfileManager().getDefaultProfile();
      }

      String forwardPrefix;
      String parsedIntro;

      if (up != null && up.getMailProperties() != null) {
        forwardPrefix = up.getMailProperties().getProperty("forwardPrefix", Pooka.getProperty("Pooka.forwardPrefix", "> "));
        parsedIntro = parseMsgString(mMsg, up.getMailProperties().getProperty("forwardIntro", Pooka.getProperty("Pooka.forwardIntro", "Forwarded message from %n:")), true);
      } else {
        forwardPrefix = Pooka.getProperty("Pooka.forwardPrefix", "> ");
        parsedIntro = parseMsgString(mMsg, Pooka.getProperty("Pooka.forwardIntro", "Forwarded message from %n:"), true);
      }
      parsedText = prefixMessage(textPart, forwardPrefix, parsedIntro);

    } else if (method == FORWARD_AS_INLINE) {

      String textPart = getTextPart(true, false, getMaxMessageDisplayLength(), getTruncationMessage());

      parsedText = Pooka.getProperty("Pooka.forwardInlineIntro", "----------  Original Message  ----------\n") + textPart;

    }

    newMsg.setText(parsedText);
    newMsg.setSubject(parseMsgString(mMsg, Pooka.getProperty("Pooka.forwardSubject", "Fwd:  %s"), false));

    NewMessageInfo returnValue = new NewMessageInfo(newMsg);

    // handle attachments.
    if (method == FORWARD_AS_ATTACHMENT) {
View Full Code Here

                progress.progress(totalNumOfEmails);
            else{
                for (File file : files) {
                    if (!file.isDirectory()) {
                        progress.progress();
                        MimeMessage message = f.parseFile(file, report);
                        if (message == null) {
                            report.log("file " + file.getName() + "can't be parsed");
                            return;
                        } else {
                            filterOneEmail(message);
View Full Code Here

TOP

Related Classes of javax.mail.internet.MimeMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.