Campaign Sample Forms in .NET Getting Started with Email Campaign

webservices
Administrator

This page is intended to help users use the ASP Email Campaign Form sample application.

 

1. Authentication data

 

Users will have to set up the API Key, account Username and Password in order to access the Constant Contact resources. The following features are available: add/edit Email Campaign, search for Email Campaign by its Status, list Email Campaigns, remove Email Campaign from lists or unsubscribe its Contacts Lists.

To set up the authentication data, you need to change the following keys from the web.config file, found in the project:

  • APIKey: API Application Key and is used to identify the application making an API request
  • username: Constant Contact Customer's user name
  • password: Constant Contact Customer's password.

 

2. Create Email Campaign

 

Users can create a new Email Campaign by filling out the form from the Add Email Campaign page top link.

Required fields are: Campaign Name, Subject, From Name, From Email Address, Reply Email Address, Organization Name, Address 1, City, Zip/Postal Code, Country, Atleast on ContactList checked, Content (if Email Content Format is set to HTML) or XContent (if Email Content Format is set to XHTML), TextContent.

Fields like Content or XContent must containt the exact html tags as in this example: <html>, <body>, and the entire structure of <OpenTracking>. The TextContent content must always be enclosed in <Text></Text> tags.

If Email Campaign does not exist, it will be added to the lists and you are given the message below.

Note that this only works if the specified name for this email campaign is not in use by another campaign. If the name is already in use you are notified about this uppon saving. To update an existing email campaign then you have to go to “List all Email Campaigns” and click edit on the desired item. After that you will be redirected to the page for Adding Campaign, with the fields already filled, but in this case the campaign will not be recreated, instead it will be updated with the modifications you specified informing you of the success of the operation with this message.

 

3. List Email Campaigns

 

The List all Emails Campaigns option will display all campaigns that the acount owner has. To edit a campaign you have to press the Edit button alongside of the campaign row. Note that campaigns in a different state that DRAFT can not be modified anymore.The Remove button will remove the campaign from the list but will not delete it phisically, thus the name will be blocked if you want to furthere use it.

You can filter to the list using the campaign state as criteria. Select the campaign state from the dropdownlist and press Sign-Up to apply the filtration over the campaigns you already created.

 

4. Application class diagram

 

ASP Email Campaign form uses the following types:

  • ContactList class - contains information's about a Constant Contact List
  • Email - current user emails
  • EmailCampaign - entity used for storing campaign information
  • Country - entity used to store country information (name, code)
  • State - entity used to store state information (name, code)

  • AuthenticationData class- used to store API Key, username and password for the Constant Contact REST API
  • Utility class - provides all necesary methods to create a new Contact, update an existing one, search by Contact email address, etc..
  • ConstantException class - exception thrown if communication with the Constant Contact server occured
  • ConstantAuthenticationException class - exception thrown if user credentials (API Key, username and passoword) are not valid
  • ContactComponent class - parse response streams into Contacts, creates entries for creating and updating Contacts
  • ContactListComponent class - parse response streams into Contact Lists, creates entries for creating and updating Contact Lists
  • EmailComponent class - creates entries for current user emails
  • EmailCampaignComponent class - create / edit entities of EmailCampaign format

5. Installation guide

 

In the Release/Setup folder, double click the setup.exe to begin the installation of ASP Net Sample application.

Click the Next button then choose the Site where this application will be installed. Also the Virtual directory name can be specified.

Pressing the Next button will guide you to the Confirmation Step. Pressing again the Next button will start the installation process. After it is completed press the Close button to close the wizard.

Before staring the sample API Key, Username and Password must be defined. To do that, you should edit the web.config configuration file from the %SystemDrive%\Inetpub\wwwroot\EmailCampaignSetup folder.

Note: If you changed the Virtual directory when installing the sample then you should found the web.config file in the following folder %SystemDrive%\Inetpub\wwwroot\[virtual_directory] ([virtual_directory] it should mach the folder you specified for the Virtual directory).

Open the configuration file and edit the following key values: APIKey, username, password.

To view the sample open a browser and type in the following address http://localhost/EmailCampaignsSetup and press enter.

 

6. How-To use it

 

The [BaseFolder]\EmailCampaigns.sln file represents the Visual Studio 2008 solution project for this application and is composed of three projects: two class library projects (EmailCampaigns.Business and EmailCampaigns.Data) and the web project itself (EmailCampaigns.Web - provides access to the following .NET wrapper objects: Contact Lists, Contact, Email, EmailCampaign, Country, State; BusinessUtility - provides access to utility methods to create a new EmailCampaign, update an existing one, search campaign by State, etc).

The EmailCampaigns.Data project consists of the following files: Contact.cs (contains information's about a Constant Contact), ContactList.cs (contains information's about a Constant Contact List), Email.cs (contains information regarding current user's emails), Country.cs & State.cs (contains information about country and state), EmailCampaign.cs (the most important model that will contain infromation of the actual email campaign), Enums.cs (used enums describing different states or properties) and one class diagram file named ClassDiagram.cd that describes the structure of EmailCampaigns.Data project.

The EmailCampaigns.Business project consists of the following files: ContactComponent.cs (contains class used parse response streams into Contacts, creates entries for creating and updating Contacts, etc.), ContactListComponent.cs (contains class used to parse response streams into Contact Lists, creates entries for creating and updating Contact Lists, etc.), AuthenticationData.cs (contains class used to store API Key, username and password for the Constant Contact REST API), EmailCampaignComponent.cs (parse response into Email Campaign - creating entity, updating or searching for it), EmailComponent.cs (parsing streamed information into user email model), BusinessUtility.cs (provides utility methods to create a new Campaign, update an existing one, filter, etc.), Utils.cs (utility methods used in processing information) and one class diagram file named ClassDiagram.cd that describes the structure of theEmailCampaigns.Business project.

 

The web project consists of the following files:

  • ConstantContact.cs - this class contains API Key, Username and Password used to acces Constant resources. Also, it contains definition for State/Province and Country
  • AddCampaignConfirmation.aspx - Campaign created/edited confirmation page
  • AddCampaignConfirmation.aspx.cs - Code behind of the AddCampaignConfirmation.aspx
  • AddEmailCampaign.aspx - Page for creating/editing a campaign
  • AddEmailCampaign.aspx.cs - Code behind of the AddEmailCampaign.aspx
  • ListEmailCampaigns.aspx - Page used to list or search campaigns
  • ListEmailCampaigns.aspx.cs - Code behind of the ListEmailCampaigns.aspx
  • Default.aspx - main page of the sample
  • Default.aspx.cs - code behind of the main page
  • Master.master - master page that displayes the menu and the company logo
  • Master.master.cs - code behind of the master page
  • Web.Config - configuration file that exposes the APIKey, Username and Password used to access Constant Contact REST API.
  • InputData/countries.txt - list of countries and their codes, countries used in the application
  • InputData/states.txt - list of U.S. states and their codes, U.S. states used in the application

If you want to import pages from this sample into your web site, you need to:

  1. add the following files into your ASP web project:
    • the ConstantContact.cs file. It should be imported into the App_Code folder of your web project
    • the desidered web page(s), both .aspx and .aspx.cs files
    • the master page Master.aspx and Master.aspx.cs (optionally, but if you don't add it into your project you need to edit the imported page, to not be displayed using a master page)
    • the ConstantContactLogo.jpg Constant Contact logo (optionally and only if the master page was added)
  2. edit the Web.Config file of the project, by adding the following code:

 

   1:  <configuration>
   2:    <appSettings>
   3:    <!--API Application Key and is used to identify the application making an API request-->
   4:      <add key="APIKey" value=""/>
   5:      <!--Constant Contact Customers user name-->
   6:      <add key="username" value=""/>
   7:      <!--Constant Contact Customers password-->
   8:      <add key="password" value=""/>
   9:    </appSettings>    
  10:  </configuration>
  11: 

 

 3. add references to your project for the following assemblies: EmailCampaigns.Business.dll and EmailCampaigns.Data.dll (from the [BaseFolder]\Bin\Debug folder)

 

 4. customize the page as you want (e.g. change some displayed text, remove unwanted fields).

Community Knowledge Base

Learning & Resources

We take questions asked by customers on the Community and expand on them to help you find answers fast, getting you back to using Constant Contact's suite of amazing tools in no time.

Read More

  • Avatar

    Support Tips

    Social Media

    "There's a multitude of ways to engage your audience through us using your social platforms - via ads, social post metrics, email links, and more! " - Will

    See Article
  • Avatar

    Support Tips

    Call-To-Action Links

    "Target your most engaged contacts by creating a segment. Create a special offer or show your appreciation!" - Caitlin

    See Article
  • Avatar

    Support Tips

    Welcome Your Audience

    "Greet new contacts with one or more automated Welcome Emails depending on their interests or your business goals." - Nick

    See Article