function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
transcendtranscend 

Email2Case authenticating to Exchange Server 2007

Hi I'm trying to setup Email2Case and getting the following error:

ERROR Unable to connect to mail service.

Message: No login methods supported!;
  nested exception is: com.sun.mail.iap.ProtocolException: No login methods supported!

Does anyone have instructions on Exchange 2007 setup? or any more info on this error?

<configFile>
    <server1>
        <url>mail.mydomain.com</url>
        <protocol>imap</protocol>
        <userName>support@mydomain.com</userName>
        <password>myPassword</password>
        <interval>5</interval>
        <inbox>Inbox</inbox>
        <readbox>movedToSalesForce</readbox>
        <errorbox>error</errorbox>
    </server1>
</configFile>


Message Edited by transcend on 02-20-2008 03:18 PM
paul-lmipaul-lmi
there's actually a better way to do this, using Apex Email Services.

you essentially create your generic email list in Exchange, and have it also deliver to the services email you generate in the org.  that then will run an Apex Class you create.

there's an excellent example of creating tasks on the wiki that can easily be modified to create cases instead.

here's a code example that I have in play.  I have an S-Control on the Case page layout that takes the webemail and webname fields and creates/updates a contact and associates it with the case, so i don't do it in the class itself, yet.

Code:
global class emailCreateCase implements Messaging.InboundEmailHandler {

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, 
                                                  Messaging.InboundEnvelope env){

// Create an inboundEmailResult object for returning 
// the result of the Force.com Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

// Add the email plain text into the local variable
string myPlainText = email.plainTextBody;

// new Task object to be created
Case[] newCase = new Case[0];

    // Try to lookup any contacts based on the email from address
    // If there is more than 1 contact with the same email address
    // an exception will be thrown and the catch statement will be called
try {
  // Add a new Task to the contact record we just found above
   newCase.add(new Case(Description = myPlainText,
     Subject = email.subject,
     Origin = 'Email',
     SuppliedEmail = email.fromAddress,
     SuppliedName = email.fromName));

  // Insert the new Task and it will be created and appended to the contact record
      insert newCase;  
System.debug('New Task Object: ' + newCase );
}
   // If there is an exception with the query looking up
   // the contact this QueryException will be called.
   // and the exception will be written to the Apex Debug logs

   catch (System.QueryException e) {
   System.debug('Query Issue: ' + e);
}

// Set the result to true, no need to send an email back to the user
// with an error message

  result.success = true;

  // Return the result for the Force.com Email Service
  return result;
}

static testMethod void testCases() {

// Create a new email and envelope object
   Messaging.InboundEmail email = new Messaging.InboundEmail();
   Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();

// Create the plainTextBody and fromAddres for the test
 email.plainTextBody = 'Here is my plainText body of the email';
 email.fromAddress ='rmencke@salesforce.com';

emailCreateCase caseObj = new emailCreateCase();
caseObj.handleInboundEmail(email, env);
} 

}

 hope this helps


paul-lmipaul-lmi
i'll also note that unless your email server has IMAP support enabled, email2case will not work at all.  I don't believe IMAP is enabled in Exchange by default (and I have no idea whether it supports it or not).
werewolfwerewolf
This last point is key -- IMAP must be enabled on Exchange, although I'm pretty sure it is on by default because that's how Outlook connects.

The one thing Paul's code won't do is thread emails into existing cases as E2C does.  Don't worry, though, we're working on something for that... :)
paul-lmipaul-lmi
me too.  i'm going dump the case number or case.id into the email somewhere, and then parse for it when the apex class picks an email up.  if found, add to existing, if not found, create a new case.  done.

I believe that's all E2C does, except it's more graceful in using a thread id, which we don't have in this scenario.  Also, using an apex email service class allows you to be more creative with what happens _after_ you add the email to the existing case, like, changing status, reopening, etc.

is that pretty much what you were planning?


Message Edited by paul-lmi on 02-22-2008 02:39 PM
transcendtranscend
I definitely need the case ID threading, can you post that when you finish it.

IMAP is enabled on my exchange server, but uses SSL, I don't see a way with Email2Case to specify SSL.
werewolfwerewolf
Did you try changing the protocol in your E2C config to imaps?
JayBNAJayBNA

Could Apex Email Services be used to also create Contacts if a support case arrives from an unknown customer?

Thanks, Jay

paul-lmipaul-lmi
absolutely.  i currently use an s-control for this, but porting that to apex code would be more elegant.
transcendtranscend
thanks, imaps worked.

If anyone gets some APEX code working that handles threading the emails to cases and new contact creation, please post. I don't have time at the moment to get that working, but that seems like a much better solution.
JayBNAJayBNA
Ditto to that.  This seems to be a perfect AppExchange tool to eliminate the need entirely for the Email-to-Case app completely.


paul-lmipaul-lmi
just finished threading.  it involves putting :::{!case.id}::: at the bottom of all your email templates though.  The email to case probably does this in a more elegant way, but this is what i was able to do.

it takes a regex and searches the body of the email for it.  returns the case.id, which will then trigger a new Task to be created rather than a Case, and in that Task, the WhatId is set to the CaseId, so it rolls up to the case.

After that, the Case status is changed to "Email from Customer", which effectively reopens it.  I don't change the owner, as I use Escalation rules to do that if a case is in a certain status for too long (it will re-queue it).

How does this sound?

(Once I have threading fully tested, code covered, and running in our production environment, I'll post the code to the wiki and start on the Contact creation)
JayBNAJayBNA

I eagerly await a chance to test! 

:smileyhappy: Jay

paul-lmipaul-lmi
just and FYI, you will most likely need to customize it.  mine isn't completely generic and references unique/custom stuff in our org. 
werewolfwerewolf
And don't forget that there is one thing this code won't do: it can't run assignment rules, since Apex can't kick off assignment rules (as of this writing anyway -- that may change in Winter '09 or a future release).
Mads TroelsenMads Troelsen
To those of you seeking help to the "No login methods supported" error when trying to connect with IMAP on Exchange 2007, I can recommend checking your IMAP4 settings in the Client Access part of your exchange server. The authentication is normally set to TLS (secure), but if it has to run with IMAP (not secure), it has to be set to basic authentication (NO-TLS).
 
Hope this is helpful to someone.
 
- Mads
jduhlsjduhls
We are getting:

Message: AUTHENTICATE failed.

...when trying to connect to Exchange 2007 (IMAP enabled, etc.)