All Projects → sendgrid → Sendgrid Apex

sendgrid / Sendgrid Apex

SendGrid (http://sendgrid.com) Apex helper library.

Labels

Projects that are alternatives of or similar to Sendgrid Apex

Salesforcedx Vscode
Salesforce Extensions for VS Code
Stars: ✭ 653 (+1878.79%)
Mutual labels:  apex
Salesforce Apex Templates
Looking for a possibility to use Email Templates within APEX code? Here's the answer!
Stars: ✭ 22 (-33.33%)
Mutual labels:  apex
Apex Test Tracker
Lightweight native continuous integration tool for Salesforce
Stars: ✭ 12 (-63.64%)
Mutual labels:  apex
Sf Build Scripts
Build and Deploy Scripts for Salesforce projects
Stars: ✭ 5 (-84.85%)
Mutual labels:  apex
Salesforce Lightning Datatable
Simple Datatable which takes SOQL query and creates native lightning datatables
Stars: ✭ 19 (-42.42%)
Mutual labels:  apex
Apex Chainable
Chain Batches in a readable and flexible way without hardcoding the successor.
Stars: ✭ 27 (-18.18%)
Mutual labels:  apex
Sfdc Trigger Framework
A minimal trigger framework for your Salesforce Apex Triggers
Stars: ✭ 527 (+1496.97%)
Mutual labels:  apex
Pytorch Auto Drive
Segmentation models (ERFNet, ENet, DeepLab, FCN...) and Lane detection models (SCNN, SAD, PRNet, RESA, LSTR...) based on PyTorch 1.6 with mixed precision training
Stars: ✭ 32 (-3.03%)
Mutual labels:  apex
Up Node8
The way this project is packaging the Node 8 app isn't the best. Try the official example of Apex Up that uses the Node binary!
Stars: ✭ 22 (-33.33%)
Mutual labels:  apex
Cdev Server
Development REST API for InterSystems Caché 2014.1+
Stars: ✭ 11 (-66.67%)
Mutual labels:  apex
Visualforce
Visualforce examples and snippets
Stars: ✭ 6 (-81.82%)
Mutual labels:  apex
Squery
Salesforce SOQL query builder
Stars: ✭ 16 (-51.52%)
Mutual labels:  apex
Affiliationsecurity
HEDA Affiliation-Based Security for Salesforce
Stars: ✭ 8 (-75.76%)
Mutual labels:  apex
Sfdc Add Contacts To Campaign Report Service
Uses Apex Analytics API to add contacts from a report as campaign members.
Stars: ✭ 5 (-84.85%)
Mutual labels:  apex
Df17 Ant To Sfdx
Metadata repository demonstrating move from Ant Migration Tools to the Salesforce CLI
Stars: ✭ 20 (-39.39%)
Mutual labels:  apex
Fflib Apex Common
Common Apex Library supporting Apex Enterprise Patterns and much more!
Stars: ✭ 536 (+1524.24%)
Mutual labels:  apex
Fflib Apex Common Builder
Builder Extension library to fflib_apex-common
Stars: ✭ 25 (-24.24%)
Mutual labels:  apex
Game Cheating Tutorial
热门网络游戏辅助开发教程
Stars: ✭ 961 (+2812.12%)
Mutual labels:  apex
Sfdc Debug Logs
Browser extension for Salesforce logs management
Stars: ✭ 28 (-15.15%)
Mutual labels:  apex
Force.com Utility Library
Salesforce Utility
Stars: ✭ 9 (-72.73%)
Mutual labels:  apex

sendgrid-apex

This Apex Toolkit allows you to quickly and easily send emails through SendGrid using Salesforce Apex.

SendGrid sendgrid = new SendGrid('username', 'password');

SendGrid.email email = new SendGrid.Email();
email.addTo('foo@bar.com');
email.setFrom('me@bar.com');
email.setSubject('Subject goes here');
email.setText('Hello World!');

String response = sendgrid.send(email);

Installation

To start using the SendGrid Apex Toolkit in your Salesforce Org, install the unmanaged package of the library with the following URL:

1.0: https://login.salesforce.com/packaging/installPackage.apexp?p0=04tF0000000SwjP

Click Continue -> Next -> Next -> Install.

Usage

To begin using this library, initialize the SendGrid object with your SendGrid credentials.

SendGrid sendgrid = new SendGrid('username', 'password');

Add your message details.

SendGrid.email email = new SendGrid.Email();
email.addTo('foo@bar.com');
email.setFrom('me@bar.com');
email.setSubject('Subject goes here');
email.setText('Hello World!');
email.setHtml('<strong>Hello World!</strong>');

Send it.

String response = sendgrid.send(email);

addTo

SendGrid.email email = new SendGrid.Email();
email.addTo('email@example.com');
email.addTo('email2@example.com');

setTos

SendGrid.email email = new SendGrid.Email();
List<String> tos = new List<String> { 'setTos@mailinator.com' };
email.setTos(tos);

setFrom

SendGrid.email email = new SendGrid.Email();
email.setFrom('foo@bar.com');

setFromName

SendGrid.email email = new SendGrid.Email();
email.setFromName('Example Lady');

setReplyTo

SendGrid.email email = new SendGrid.Email();
email.setReplyTo('foo@bar.com');

Bcc

Use multiple addTos as a superior alternative to setBcc.

SendGrid.email email = new SendGrid.Email();
email.addTo('foo@bar.com');
email.addTo('someotheraddress@bar.com');
email.addTo('another@another.com');
...

But if you do still have a need for Bcc you can do the following.

SendGrid.email email = new SendGrid.Email();
email.addBcc('foo@bar.com');

setSubject

SendGrid.email email = new SendGrid.Email();
email.setSubject('This is a subject');

setText

SendGrid.email email = new SendGrid.Email();
email.setText('This is some text');

setHtml

SendGrid.email email = new SendGrid.Email();
email.setHtml('<h1>This is an html email</h1>');

addSubstitution

SendGrid.email email = new SendGrid.Email();
List<String> vals = new List<String> { 'val' };
email.addSubstitution('sub', vals);

addUniqueArg

SendGrid.email email = new SendGrid.Email();
email.addUniqueArg('add_unique_argument_key', 'add_unique_argument_value');

addCategory

SendGrid.email email = new SendGrid.Email();
email.addCategory('Category 1');
email.addCategory('Category 2');

addSection

SendGrid.email email = new SendGrid.Email();
email.addSection('set_section_key', 'set_section_value');

addFilter

SendGrid.email email = new SendGrid.Email();
email.addFtiler('footer', 'text/html', '<strong>boo</strong>');

addHeader

You can add standard email message headers as necessary.

SendGrid.email email = new SendGrid.Email();
email.addTo('foo@bar.com');
...
email.addHeader('X-Sent-Using', 'SendGrid-API');
email.addHeader('X-Transport', 'web');

addAttachmentStream

SendGrid.email email = new SendGrid.Email();

// as a string
email.addAttachmentStream('text.txt', 'somerandomcontentyouwant');

// as a blob
String text = 'This is an attachment.';
Blob as_blob = Blob.valueof(text);
email.addAttachmentStream('text.txt', as_blob);

Development

Getting your development environment setup takes some careful steps. So, we have explained the process here to save you some time:

Setup Salesforce.com

Create a salesforce.com developer account.

You'll receive an email from Salesforce with a link to confirm. Click it.

On the next screen, set your password.

You now have a developer account.

Generate your security token. We will need this later. While logged into your developer account, click "Your Name > My Settings" at the top right portion of your developer account dashboard.

Then on the left side of the screen click "Personal > Reset My Security Token". Click the "Reset Security Token" button. Salesforce emails you a security token. You will need this later.

Setup local environment

Install Sublime Text 3.

Install Mavens Mate.

Open up Sublime Text 3, and then open up Mavens Mate on your machine. There should be a Mavens Mate icon, at the top bar of your screen. Click it and then click "Plugins".

On the next window, click "Install Plugin". This installs the Mavens Mate plugin into Sublime Text 3.

Close and reopen Sublime Text 3.

Click Mavens Mate > Settings > User at the top Sublime Text 3 Toolbar.

This will open a file called mavensmate.sublime-settings. Paste the following in that file. Adjust to the path and directory you want to store your salesforce code in. It must be an absolute path.

{
  "mm_workspace": "/Users/your_username/code/salesforce"
}

Save and close that file.

Clone the repo

cd /Users/your_username/code/salesforce
git clone https://github.com/sendgrid/sendgrid-apex.git

Open the project

With Sublime Text 3 still open, click "File > Open", and open the sendgrid-apex folder.

Create the project on Salesforce

Right click on the sendgrid-apex containing folder, and choose "MavensMate > Create MavensMate Project".

On the next screen enter the following:

  • For project name: 'sendgrid-apex'
  • For username: enter your email address
  • For password: enter your password APPENDED with your salesforce security token. (see above for how to generate the security token)

When you're ready click the 'Create Project' button.

This will create the project up on Salesforce.com and locally on your machine. That's what we want.

Next, the final and most important step.

Click "Mavens Mate > Project > Compile Project".

You're done

You're done!

Now go ahead and develop. I recommend this tutorial or this blog post for learning some basics of developing with Apex.

Additional: Creating the unmanaged package.

Search for "packages".

Click "Create > Packages".

Click "New" under Packages.

Name the package "sendgrid-apex" and click save.

On the list of packages screen, now click "sendgrid-apex".

On the next screen under components, click "Add".

On the next screeen choose "Apex Class" under Component Type.

Check all the SendGrid related classes.

Then click "Add to Package".

Then click "Add" again.

This time on the next screen choose "Remote Site".

Check the SendGrid Remote Site, and click "Add to Package".

Then on the package show page, click "Upload".

On the next screen, enter "052114-sendgrid-apex" for the name (change the mm/dd/yy to the current).

Set version number to 1.0.

Set the description to: "This Apex Toolkit allows you to quickly and easily send emails through SendGrid using Salesforce Apex."

Scroll down to the very bottom and click "Upload".

Copy and paste the installation url and place in the README.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].