email Connector Boinitasoft not working

hello

Thanking you for just replying me ze.

When  i reply bonitasoft says access denied,so i create a new topic ,hope it works

yes there are some java codes when you implement the connector.

I have follow a video which was made in French here:

http://fr.bonitasoft.com/ressources/videos/creez-votre-propre-connecteur-bonita-bpm-6.

if you need further information to help me please ask.

I put it here what i have use in the java code:

/**
 *
 */
package org.mycompany.connector;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

import javax.mail.Flags;
import javax.mail.Flags.Flag;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;

import org.bonitasoft.engine.connector.ConnectorException;


/**
 *The connector execution will follow the steps
 * 1 - setInputParameters() --> the connector receives input parameters values
 * 2 - validateInputParameters() --> the connector can validate input parameters values
 * 3 - connect() --> the connector can establish a connection to a remote server (if necessary)
 * 4 - executeBusinessLogic() --> execute the connector
 * 5 - getOutputParameters() --> output are retrieved from connector
 * 6 - disconnect() --> the connector can close connection to remote server (if any)
 */
public class EmailReceiverConnector1Impl extends
        AbstractEmailReceiverConnector1Impl {    
    
2    Logger logger  = Logger.getLogger("org.bonitasoft.emailtest");
    private Store emailStore;
    private Folder inbox;
    

    @Override
    protected void executeBusinessLogic() throws ConnectorException{
        //Get access to the connector input parameters
        //getEmailHost();
        //getAccountUsername();
        //getAccountPassword();
        
        List mails = new ArrayList<Map<String, String>>();
        try {
            Message[] messages = inbox.search(new FlagTerm(new Flags(Flag.SEEN), false));
            for (Message message : messages) {
                HashMap<String, String> mailMap = new HashMap<String, String>();
                mailMap.put("subject", message.getSubject());
                if (message.isMimeType("Multipart/*")) {
                    Multipart multipart = (Multipart) message.getContent();
                    for (int i = 0; i < multipart.getCount(); i++) {
                        if (multipart.getBodyPart(i).isMimeType("text/plain")) {
                            mailMap.put("body)",(String) multipart.getBodyPart(i).getContent());
                            
                        }
                    }
                }
                mails.add(mailMap);
                message.setFlag(Flag.SEEN, true);                
            }
            setEmails(mails);
        } catch (Exception e) {
            logger.severe(e.getMessage());
            setEmails(mails);
        }            
        
    
        //WARNING : Set the output of the connector execution. If outputs are not set, connector fails
        //setEmails(emails);
    
     }

    @Override
    public void connect() throws ConnectorException{
        //[Optional] Open a connection to remote server
        Properties properties = new Properties();
        properties.setProperty("mail.store.protocol","imaps");
        
        Session session = Session.getDefaultInstance(properties);
        try {
            emailStore = session.getStore("imaps");
            emailStore.connect(getEmailHost(), getAccountUsername(),
                    getAccountPassword());
            inbox = emailStore.getFolder("Inbox");
            inbox.open(Folder.READ_WRITE);    
        } catch (Exception e) {
            logger.severe("Failed to get store - " + e.getMessage());
            throw new ConnectorException(e);
        }
        
    }

    @Override
    public void disconnect() throws ConnectorException{
        //[Optional] Close connection to remote server
        try {
            inbox.close(false);
            emailStore.close();
        } catch (MessagingException e) {
            throw new ConnectorException(e);
        }
        
        
    }

}

 

I download the jar files here that is mail .jar and activation.jar:

http://www.java2s.com/Code/Jar/a/Downloadactivationjar.htm

Hello ryanphenix11

Can you post the complete log? 

Regards

Hi ze

thks for answering.

But what do you mean by complete log??

Tell me please.

I already posted the whole java i written in the code.

Regards

Depending of you server, you have the logs in the logs folder. ex, in tomcat it's in your tomcat/logs folder. If you are testing it in the studio, you can see both bonita and engine logs in the "help" menu. This logs can be useful in order to find what is exactly happen.