You need to sign in to do that
Don't have an account?
IMAP server Acesses through Apex ??????
helooo
i want to acesses IMAP server in salesforce but i m unable to do it .. i m not having any idea how to write in Apex Down hear i m writing the code in java . in the same manner i want t o write in Apex . please can any one guide me how to write in Apex. ???
ex;- i dint found any session class,properties class, or methods in apex , can u guide me please ...
thanks in advance
sam
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store;
public class InboxReader {
public static void main(String args[]) {
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "<username>", "password");
System.out.println(store);
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message messages[] = inbox.getMessages();
for(Message message:messages) {
System.out.println(message);
}
} catch (NoSuchProviderException e) {
e.printStackTrace();
System.exit(1);
} catch (MessagingException e) {
e.printStackTrace();
System.exit(2);
}
}
}
IMAP is not currently supported in Apex Code, as that would require two-way communication (i.e. a socket) that can have multiple back and forth responses; salesforce.com only supports REST and SOAP calls. It would be conceptually possible to write a web service function that interacts with an IMAP server (e.g. server software that interacts with the IMAP server and receives requests via SOAP), but you'd be limited to retrieving only a handful of messages per request.
helloo
i realy apriciate for ur valuble replay . .
but it definetly possible , because with out tat how come so many integrated salesforce with gmail???
i m trying to integrate salesforce to gmail .. help me out pls
regards sam........
Current implementations of IMAP use an external service to bridge the connection between salesforce.com and the IMAP server. It looks like this:
salesforce.com Apex Code <-> Custom IMAP Bridge <-> IMAP Service
The middle part is what makes the connection possible. The salesforce.com Apex Code calls a REST or SOAP service to the Custom IMAP Bridge, which in turn calls the IMAP functions to retrieve folders and messages, which is then returned back to the salesforce.com Apex Code.
heloo
can u please elobirate coustom IMAP Bridge
thank u ..
An IMAP bridge is simply a piece of software that has an API endpoint and IMAP connectivity. I'd imagine that such a service probably has at least a few functions:
login(username, password)
getfolderlist(session)
getfoldercontents(session,foldername)
removemessage(session,messageid)
After the software is written and compiled, then it can run on a server, listening for soap or rest messages (the implementation doesn't really matter, so long as each side understands each other).
From there, your Apex Code would call login(), get the session id, then use the other functions to manipulate data.
Alternatively, the server software can use the salesforce.com api and the imap api directly.