Matt Paulson

Entrepreneur, Author, Private Equity Investor
  • Facebook
  • Linkedin
  • Twitter
  • Rss
  • Blog
    • Book Recommendations
    • Church Life & Ministry
    • Community Projects
    • Entrepreneurship
    • Quaterly Updates
    • Startup Community
    • Startup Q&A Show
    • Web Development
  • About
    • Resume
  • My Companies
    • Angel Investments
  • My Books
    • Online Business from Scratch
    • Automatic Income
    • The Ten-Year Turnaround
    • Email Marketing Demystified
    • 40 Rules for Internet Business Success
    • Business Growth Day by Day
    • Simple Savings
  • Media Appearances
  • Contact
Home» Blog » How to Implement the SendGrid Newsletter API in ASP.NET and C#

How to Implement the SendGrid Newsletter API in ASP.NET and C#

Posted on June 18, 2013 by matt in Blog, Entrepreneurship, Web Development 2 Comments
Tweet

sendgridA while back, SendGrid announced its newsletter functionality that provides functionality for managing and emailing distribution lists. If you’re a developer that makes use of SendGrid, you’re probably managing your list internally in a SQL database and have no need for SendGrid’s newsletter functionality, but there are two distinct advantages to using the Newsletter API.The first major advantage is that you can email a distribution list of any size with a single API call, which is much more efficient than trying to email a large distribution list one-by-one or in groups via SMTP.

The second major advantage is cost. Sending email through the newsletter API is about 45% cheaper than sending mail through SMTP or SendGrid’s Web API ($0.25 per 1,000 emails vs. $0.45 per 1,000 emails. This might not matter if you’re using a small volume, but it can make a difference on your bill if you’re sending out 1,000,000 or more emails each month. I saved about $250.00 per month from switching the majority of the messages sent by my server to using the Newsletter API, since my primary business is sending out a daily newsletter.

SendGrid does have a C# library that does a great job of sending messages through the Web API, but it does not currently support the newsletter API. Since I implemented the Newsletter API in my C# code-base, I thought I’d pass along a class I wrote called “SendGridTools” I wrote in the event that someone else wants to make use of the SendGrid Newsletter API in ASP.NET.

I’ve included most all of the common functions that should be needed:

  • List Management Functions
    • CreateDistributionList (Creates a new email distribution list)
    • DeleteDistributionList (Deletes a email distribution list)
  • Recipient Management Functions
    • AddEmailToList (Adds an email to a distribution list)
    • AddMultipleEmailstoList (Adds lots of emails to a distribution list)
    • DeleteEmailFromList (Remove a user from a distribution list)
  • Delivery Functions
    • SendNewsletterToList (Send a message to a distribution list)

To make use of this class, simply import the C# file into the AppCode folder of your website or web-application and specify your SendGrid account credentials in the header of the class. The methods are based out of a simple static class titled “SendGridTools”.

Here’s some example code that makes use of the class. The code below creates a distribution list called “mylist”, adds three emails to that list and sends a message to that list.

SendGridTools.CreateDistributionList("mylist");
SendGridTools.AddEmailToList("[email protected]", "example 1", "mylist");
SendGridTools.AddEmailToList("[email protected]", "example 2", "mylist");
SendGridTools.AddEmailToList("[email protected]", "example 3", "mylist");
SendGridTools.SendNewsletterToList("from name", "my newsletter", "this is my newsletter body", "mylist");

Click Here to Download the C# Class “SendGridTools”  (12KB)

You are free to use the provided library for any commercial or non-commercial purpose. I release it to the public domain and do not reserve any copyright to it. Have questions about this library or suggestions to improve it? Feel free to make suggestions in the comments below. 

Tweet

Comments

2 comments on “How to Implement the SendGrid Newsletter API in ASP.NET and C#”

  1. Jon White says:
    May 12, 2015 at 6:33 pm

    Hey Matt, Curious if you're still using this code? I'm having issues with AddMultipleEmailstoList. I just keep getting the error "A Database Error has occured" from SendGrid. Adding individual emails works fine.

    Reply
  2. Matthew Paulson says:
    June 18, 2015 at 1:34 am

    Nope. I stopped using their newsletter API because of the pricing.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Email Updates

Enter your email address below to receive a steady stream of tricks, tips and ideas to help you build a better and more profitable business.

Email Marketing Demystified

The second edition of Email Marketing Demystified is now available. This book teaches you how to build a massive email list, write marketing copy that converts and generate more sales in your business.

Click Here to Get Your Copy of Email Marketing Demystified

Recent Posts

  • Sioux Falls to Celebrate Entrepreneurship Day on March 3, 2021

    February 18, 2021
  • MarketBeat is Hiring for Three Positions (Support, Data Analyst and Web Developer)

    February 17, 2021
  • The Biggest Mistake You Can Make with Your Email Sign-Up Forms

    February 16, 2021
  • Five Lessons Learned from the MarketBeat Burger Project

    February 2, 2021
  • Seven Lessons I Learned Helping Animal Shelters Raise $18.5 Million Over Seven Years

    January 19, 2021

    Follow me on Facebook & YouTube

    Contact

    • [email protected]
    • Contact Us
    • matthew-paulson
      • Facebook
      • Twitter
      • Linkedin
      • Instagram
      • Rss

    © Matthew Paulson 2003-2021. All Rights Reserved.

    Privacy Policy