You are on page 1of 9

INTEGRATING WITH

APEX
(INTEGRATION USING
EMAIL)
Exercise Guide
EXERCISE GUIDE
Integration Using Email

Table of Contents
Exercise 4-1: Integrating with Force.com Email Services ............................................................... 1
Appendix A – Generating a Security Token .................................................................................... 3
Appendix B – Registering Visual Studio.......................................................................................... 4
Appendix C – Create Your Own Instances of the Workbench and Axiom Applications ............... 5
Appendix D – Connecting through a Proxy Server......................................................................... 6
EXERCISE GUIDE
Integration Using Email

Exercise 4-1: Integrating with Force.com Email Services


Scenario:
Universal Containers wants to provide an easy way for candidates to submit their resumes
through the corporate website without building a full API website integration. Using Email
Services, they can accomplish this.
Goals:
 Configure an email service.
 Test an Email Services integration.
Tasks:
1. Configure a Force.com Email Service.
2. Test the Email Service-based integration.
3. Locate and Study the Email Service solution code.
Time:
10 minutes

Instructions:
1. Configure a Force.com email service.
A. Log in to Salesforce, navigate to Setup | Develop | Email Services and click New
Email Service.
B. Populate the form with the following values:
Email Service Name: CandidateEmailService
Note: You may need to type this in if it does not appear in the list.
Apex Class: CandidatePositionEmailHandler
Accept Attachments: All
Active: Checked
Failure Response Settings: Bounce Message (for all options)
C. Click Save and New Email Address.
D. On the following page, clear out any values specified on the Accept Email From
textbox.
E. Click Save.
F. Take note of the email address listed in the Email Address field.
2. Test the Email Service.
A. In Salesforce, navigate to the Home tab and click the Position Application Form link
within the Custom Links section on the sidebar.

©Copyright 2016 salesforce.com, inc. All rights reserved. 1


EXERCISE GUIDE
Integration Using Email

B. Enter information in the following fields provided to create a Candidate and


Application: First Name, Last Name, Email, Phone, Position Applying For,
Comments, and Resume.
C. In the Email Service Address field, enter the email address of your Email Service that
you noted in step 1.f.
D. Optionally, in the Carbon Copy Email Address field, enter a web-accessible personal
email address to receive a copy of the email sent from the application to the Email
Service.
E. Click Submit. You should see a message telling you an email was sent and the form
was submitted successfully.
F. Log in to Salesforce and search for the Candidate name you entered in the Web
form to validate the submission of the information, paying attention to the
following:
i. Locate the uploaded resume.
ii. Locate the related Application record for the position specified.
G. Optionally, log in to the personal email address you specified on the form and
observe the format of the email that was generated and sent by the Web application
to the Email Service. Note that it could take several minutes for this email to appear
in your inbox.
3. Locate and study the solution code.
A. Navigate to Setup | Develop | Apex Classes.
B. Click on the CandidatePostionEmailHandler class to observe the logic required
to handle and process inbound emails.

Review
1. How was the Apex email handler class able to read in values from the inbound email
body and map them to Salesforce object fields?

2. What architectural changes might you make to this email “integration” if you were to
implement this using your real corporate website?

©Copyright 2016 salesforce.com, inc. All rights reserved. 2


EXERCISE GUIDE
Integration Using Email

Appendix A – Generating a Security Token


Scenario:
You are going to use an API to access Salesforce from outside the trusted IP range. You
need to generate a security token for access.
Tasks:
1. Customize the admin user to use your email.
2. Generate a security token.

Instructions:
1. Customize the admin user to use your email.
A. Navigate to Your Name | My Settings | Personal | Personal Information.
B. Modify the Email field to be an email address you can access during class.
C. Click Save.
2. Generate a security token.
A. Navigate to Your Name | My Settings | Personal | Reset My Security Token.
B. Click on Reset Security Token.
C. Look in your email for the token.

©Copyright 2016 salesforce.com, inc. All rights reserved. 3


EXERCISE GUIDE
Integration Using Email

Appendix B – Registering Visual Studio


1. Make sure that you have your MSDN ID and password available, as this is required to
register Visual Studio.
2. Open Visual Studio by navigating to Start | Programs | Microsoft Visual C# Express
Edition.
3. From the drop-down menu, select Help | Register Product.
4. Click Register Now.
5. In the browser window that opens, enter your MSDN ID and password and click Sign
in.
6. Scroll to the bottom of the page and click Continue.
7. Copy the registration key provided on this screen.
8. Return to the Visual Studio screen, and paste the password into the Registration key:
field.
9. Click Complete Registration.
10. In the dialog box that appears, click No, I would not like to participate.
11. Click Close.

©Copyright 2016 salesforce.com, inc. All rights reserved. 4


EXERCISE GUIDE
Integration Using Email

Appendix C – Create Your Own Instances of the Workbench and Axiom Applications
Follow these instructions to create your own instances of Workbench and Axiom by
deploying the application to Heroku.
Instructions:
1. Deploy Workbench and Axiom to Heroku.
A. For Workbench, open a new tab and navigate to
http://github.com/ryanbrainard/forceworkbench. For Axiom, open a new
tab and navigate to https://github.com/ryanbrainard/axiom.
B. Scroll down and click Deploy to Heroku.
C. Log in to Heroku.
i. If you do not have a Heroku account already:
a. Enter your name in the Full Name field.
b. Enter an email address in the Email field.
c. Click Create Free Account.
d. Log in to the email account you specified above. You will have a confirmation
email from Heroku. Click the confirmation link to activate your account.
e. Enter a password of your choice.
f. Confirm your password.
g. Click Set password and log in. Wait for Heroku to take you to the New App
setup page for Workbench or Axiom.
ii. If you already have a Heroku account:
a. Click Log In (under the Create Free Account button).
b. Enter your Heroku account credentials
c. Click Log In. Wait for Heroku to take you to the New App setup page for
Workbench or Axiom.
D. Enter a unique app name in the App Name field, or leave it blank if you would like
Heroku to create an app name for you.
E. Click Deploy for Free, and wait while the application is deployed.
F. You will see deployment progress at the bottom of the page. When the page
indicates that your app has been successfully deployed, click the View it link.

©Copyright 2016 salesforce.com, inc. All rights reserved. 5


EXERCISE GUIDE
Integration Using Email

Appendix D – Connecting through a Proxy Server


Scenario:
You are going to use an API to access Salesforce URL’s through a Proxy Server. You need to
configure your Visual Studio and Eclipse solutions to connect through this Proxy Server.
Tasks:
1. Determine and write down your Proxy Server settings.
2. Make code or configuration changes to your Visual Studio or Eclipse application.

Determine your Proxy Server Settings (Eclipse and Visual Studio)


1. The exact settings you need will vary depending on how your particular network is
setup.
A. Determine the IP address or URL of your Proxy Server, along with the Port used to
connect. Most Windows users will be able to get this information by using the
Command Prompt. Type the following command at the command prompt and
press Enter. The result could be an IPv4 address or URL followed by a colon and the
port number.
reg query
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Inte
rnet Settings" | find /i "proxyserver"
ProxyServer/Port Number: _________________________
Note: Depending on the group policy settings of you network, you may not be able
to access the information without checking with your Network or System
Administrator.
B. Optionally, you may also need to determine the NT Domain name of your Proxy
Server. If you do not know what this is, attempt to make the connection without
specifying it first.
Domain: _________________________

Instructions for Visual Studio


1. Make configuration changes to each application that requires internet access to the
Proxy Server.
A. From Solution Explorer locate the app.config and double-click the file to open it.
B. Scroll down to the bottom of the file and insert the following code right before the
ending configuration tag, or uncomment any code that is already present:
<system.net>
<defaultProxy useDefaultCredentials="true">

©Copyright 2016 salesforce.com, inc. All rights reserved. 6


EXERCISE GUIDE
Integration Using Email

<proxy usesystemdefault="True"
proxyaddress="proxyServer.corp.myCorp.com: 8080"/>
</defaultProxy>
</system.net>
Note: It is possible that the exercise file you have has commented code already
present to access the proxy server and all you will have to do is uncomment the
applicable lines of code. By setting the useDefaultCredentials parameter to
true, you should not need to enter your network credentials or NT Domain name.
Also, the proxyaddress should be the IPv4 address or URL portion of what was
returned in Step 1A above. The server address and port number values should be
separated with a colon.
C. Press Ctrl+S to save.
D. Follow the remaining exercise instructions to complete testing the solution.

Instructions for Eclipse


1. Make code changes to each application that requires internet access to the Proxy
Server.
A. From Package Explorer locate the file used to make a connection to Salesforce and
double-click the file to open it.
B. Locate the code used to authenticate with Salesforce. Enter the following line of
code below the lines used to set the username and password.

config.setProxy("proxyServer.corp.myCorp.com",8080);

Note: It is possible that the exercise file you have has commented code already
present to access the proxy server and all you will have to do is uncomment the
applicable lines of code. Also, the first part of the address should be the IPv4
address or URL portion of what was returned in Step 1A above, followed by a colon
and then the port number.
C. Optionally, specify the NT Domain name and network credentials used to access the
proxy server through the following additional lines of code:

config.setNtlmDomain("NtlmDom");
config.setProxyUsername("proxyUserName");
config.setProxyPassword("***");

D. Select File | Save.


E. Follow the remaining exercise instructions to complete testing the solution.

©Copyright 2016 salesforce.com, inc. All rights reserved. 7

You might also like