Decoding Salesforce

Decoding Salesforce

The hows and whys of Salesforce.com

Using Email2Case with Google’s Gmail

I like Google, infact, I really love many of Google’s apps. There are many reasons to use Gmail - Google’s ‘new kind of webmail’ - and one of those is that it offers IMAP access. This is great for those of you who’ve been waiting to use the Salesforce’s Email2Case tool, and today I’m going to explain how to configure it to be used with Gmail.

Email2Case? What is it?

Email2Case ‘is a toolkit that pulls emails from your mail server and uses the Force.com API to create new cases or append to an existing case‘. In order to get more information about the tool and download it, please navigate here (note you will need a free developer account to access the page, you can subscribe for one here).

Gmail, Email2Case and Salesforce configuration

  1. First of all we need to subscribe for a free Gmail Account: navigate to the Signup Page, fill in the required information and in no time you’ll have obtained a new account.
  2. Email2Case will process the Gmail Inbox folder, but we also need to create the folders (Gmail calls them Labels) where the Processed or Error emails will go: so, within Gmail, let’s click on “Settings” > “Labels” and create 2 new labels: Error and Processed. That’s it, we’re done configuring Gmail.
  3. Now we need to work on the two Email2Case config files: email2case.txt and sfdcConfig.txt. If you haven’t already done so, download the Email2Case Toolkit and navigate to the directory where you have unzipped it (I keep it in C:\Email2Case).
    • First let’s have a look at the email2case.txt. You’ll only need to change username@gmail.com and gmail_password with your newly created gmail address and password.

      <configFile>
          <server1>
              <url>imap.gmail.com</url>
              <protocol>imaps</protocol>
              <userName>username@gmail.com</userName>
              <password>gmail_password</password>
              <interval>1</interval>
              <inbox>Inbox</inbox>
              <readbox>Processed</readbox>
              <errorbox>Error</errorbox>
          </server1>
      </configFile>
    • And now sfdcConfig.txt. Once again, the changes you’ll have to make are pretty straight-forward: just change salesforce_username_here and salesforce_password_here with your real Salesforce.com username and password.
      <configFile>
          <sfdcLogin>
              <url>https://www.salesforce.com/services/Soap/u/9.0</url>
              <userName>salesforce_username_here</userName>
              <password>salesforce_password_here</password>
              <loginRefresh>30</loginRefresh>
              <timeout>5000</timeout>
          </sfdcLogin>
          <notify>
      	<notifyEmail></notifyEmail>
              <from></from>
              <host>smtp.gmail.com</host>
      	<port>465</port>
              <user></user>
              <password></password>
              <service>com.sforce.mail.SMTPNotification</service>
          </notify>
          <attachments>
              <largeAttachmentDirectory>C:\EmailAgent\LargeAttachments</largeAttachmentDirectory>
              <largeAttachmentURLPrefix>file:\\C:\EmailAgent\LargeAttachments</largeAttachmentURLPrefix>
              <largeAttachmentSize>1</largeAttachmentSize>
          </attachments>
          <services>
              <com.sforce.mail.EmailService>C:\\EmailAgent\\email2case.txt</com.sforce.mail.EmailService>
          </services>
      </configFile>
  4. We’re almost ready, the last thing to do is to enable Email2Case in Salesforce.com and verify that everything works as expected. Login onto your Salesforce.com Organization and navigate to: Setup > Customize > Cases > Email-to-Case. Follow the steps to enable Email2Case and add the gmail address we created earlier as a “Routing Address”. That’s it, we should be set!
  5. Start the Email2Case Agent by double clicking on the email2case.bat file and make sure you get no errors, send an email to the gmail address and as soon as the Email2Case will pick that up, a new case will be created in your Salesforce.com Org.

If you need further help setting up the Email2Case Agent, please refer to this Salesforce.com Help page.

Popularity: 30% [?]

Advertisement

11 Comments, Comment or Ping

  1. §

    Hey Ale,

    Any idea if Salesforce and Google can integrate in ways other than email to case? I have heard some buzz about this recently and am interested in learning more.

    Best,

    Adam
    Salesforcetimes.com

    By Adam on 11/03/2008 - 00:07

  2. §

    @Adam: Hi, I also heard about few rumours; I’ve no further information, but let’s keep the finger crossed and hope this is happening soon.

    Ale

    By Ale on 11/03/2008 - 09:45

  3. §

    I have not got this to work yet. I am getting some time out errors when I run the script. I do not think the google server is aloowing me to connect.

    By ak on 1/04/2008 - 20:05

  4. §

    @ak: Make sure IMAP is enabled on Gmail; also, can you post the errors?

    By Ale on 21/04/2008 - 15:26

  5. §

    HI all.

    Here are the errors I get when trying to connect.

    2008-04-02 08:48:14,369 7162 [main] INFO com.sforce.mail.EmailService - ReadBox : Sent Mail
    2008-04-02 08:48:14,370 7163 [main] INFO com.sforce.mail.EmailService - ErrorBox: Drafts
    2008-04-02 08:48:14,370 7163 [main] INFO com.sforce.SalesforceAgent - Service imap.googlemail.com:0:xxxxxxx@googlemail.com:Inbox successfully registered
    2008-04-02 08:48:14,370 7163 [main] INFO com.sforce.SalesforceAgent - com.sforce.mail.EmailService loaded as a timer service.
    2008-04-02 08:49:29,268 82061 [Timer-0] ERROR com.sforce.mail.GenericClient - Unable to connect to mail service.
    Service: imap.googlemail.com
    User: xxxxxxx@googlemail.com

    Message: Operation timed out;
    nested exception is:
    java.net.ConnectException: Operation timed out

    By ak on 24/04/2008 - 17:58

  6. §

    @ak: Please confirm you have enabled IMAP on Gmail; also, can you post both your config files? (hide usernames/passwords)

    By Ale on 25/04/2008 - 08:48

  7. §

    In the sfdcConfig.txt file you’ll need to append a security token to the end of your password for the service to successfully log into Salesforce.

    Nice summary. Thanks.

    By frasuy on 30/04/2008 - 20:16

  8. §

    Ale,

    I am following the instructions to test this but I am running into a problem that I don’t know if it is related to the gmail connection or the sfdc connection. I am almost sure is the sfdc connection but want to check with your expertise. Here’s the error:

    2008-10-22 13:50:13,781 60766 [main] ERROR com.sforce.mail.GenericClient - Failed to connect to SFDC service
    [UnexpectedErrorFault [ApiFault exceptionCode='UNSUPPORTED_CLIENT'
    exceptionMessage='HTTPS Required'
    upgradeURL='null'
    upgradeMessage='null'
    ]
    ]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:436)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:362)
    at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:166)
    at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:145)
    at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:95)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:76)
    at com.sforce.soap.partner.wsc.PartnerConnection.login(PartnerConnection.java:734)
    at com.sforce.mail.GenericClient.login(GenericClient.java:267)
    at com.sforce.mail.GenericClient.getConnection(GenericClient.java:179)
    at com.sforce.mail.GenericClient.(GenericClient.java:135)
    at com.sforce.mail.ImapClient.(ImapClient.java:40)
    at com.sforce.mail.ImapSSLClient.(ImapSSLClient.java:31)
    at com.sforce.mail.EmailService.loadService(EmailService.java:156)
    at com.sforce.SalesforceAgent.main(SalesforceAgent.java:138)
    2008-10-22 13:50:25,812 72797 [main] INFO com.sforce.mail.GenericClient - Will try 1 more time(s).

    On the config file I have:

    http://www.salesforce.com/services/Soap/u/9.0
    alejo@2miwasi.com
    PsswrdAndTokenInfo
    30
    5000

    smtp.gmail.com
    465

    com.sforce.mail.SMTPNotification

    C:\EmailAgent\LargeAttachments
    file:\\C:\EmailAgent\LargeAttachments
    1

    C:\\EmailAgent\\email2case.txt

    By Luis Alejandro on 22/10/2008 - 19:01

  9. §

    Ale,

    I think is working now..

    Apparently I had to use https on the url section as follows:
    https://www.salesforce.com/services/Soap/u/9.0

    By Luis Alejandro on 22/10/2008 - 19:19

  10. §

    We only want the append email part to work when emails carrying the thread id are sent to the the registered support email. When an email arrives without a thread id, we don’t want salesforce to create another case. We would prefer to manage case creation manually.

    Any ideas

    By Mac on 16/12/2008 - 00:32

  11. §

    Having spoken to Ale, he has asked me to add this comment to this blog: This wonderful explanation of how to setup email2case is out of date! SFDC is no longer using SOAP 7.0, it is now using SOAP 9.0, thus the line “http://www.salesforce.com/services/Soap/u/7.0” will no longer work. It has to be replaced with “https://www.salesforce.com/services/Soap/u/9.0”. Make sure that you set the protocol to https, not http.

    If like me this still doesn’t work for you try consulting the “Members:Email To Case” page on developer.force.com, you will have to login (to a developer account) to access this page. And of course double check all of the xml tags that they are correctly filled in.

    By Paddyozy on 23/01/2009 - 15:49

Reply to “Using Email2Case with Google’s Gmail”