summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example
diff options
context:
space:
mode:
Diffstat (limited to 'SendGrid/Example')
-rw-r--r--SendGrid/Example/Example.csproj8
-rw-r--r--SendGrid/Example/Program.cs57
-rw-r--r--SendGrid/Example/app.config4
3 files changed, 58 insertions, 11 deletions
diff --git a/SendGrid/Example/Example.csproj b/SendGrid/Example/Example.csproj
index 9569faf..60bede7 100644
--- a/SendGrid/Example/Example.csproj
+++ b/SendGrid/Example/Example.csproj
@@ -50,7 +50,10 @@
<HintPath>..\packages\SendGrid.SmtpApi.1.3.1\lib\net40\SendGrid.SmtpApi.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Web.Extensions" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
@@ -71,6 +74,11 @@
<Project>{3c687bef-ff50-44ad-8315-2d4237281af8}</Project>
<Name>Mail</Name>
</ProjectReference>
+ <ProjectReference Include="..\SendGrid\SendGrid.csproj">
+ <Project>{1c318867-440b-4eb9-99e3-c0cc2c556962}</Project>
+ <Name>SendGrid</Name>
+ <Aliases>global</Aliases>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 113e3f5..3e222a1 100644
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
using System.Net;
+using System.Net.Http;
using System.Net.Mail;
-using SendGrid;
+using SendGrid.Resources;
namespace Example
{
@@ -10,11 +11,46 @@ namespace Example
{
// this code is used for the SMTPAPI examples
private static void Main()
- {
+ {
+ String apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY", EnvironmentVariableTarget.User);
+ var client = new SendGrid.Client(apiKey);
+
+ // GET
+ HttpResponseMessage response = client.ApiKeys.Get();
+ Console.WriteLine(response.StatusCode);
+ Console.WriteLine(response.Content.ReadAsStringAsync().Result);
+ Console.ReadKey();
+
+ // POST
+ /*
+ HttpResponseMessage response = client.ApiKeys.Post("CSharpTestKey5");
+ Console.WriteLine(response.StatusCode);
+ Console.WriteLine(response.Content.ReadAsStringAsync().Result);
+ Console.ReadKey();
+ */
+
+ // DELETE
+ /*
+ HttpResponseMessage response = client.ApiKeys.Delete("<api_key_id>");
+ Console.WriteLine(response.StatusCode);
+ Console.WriteLine(response.Content.ReadAsStringAsync().Result);
+ Console.ReadKey();
+ */
+
+ // PATCH
+ /*
+ HttpResponseMessage response = client.ApiKeys.Patch("<api_key_id>", "CSharpTestKey7");
+ Console.WriteLine(response.StatusCode);
+ Console.WriteLine(response.Content.ReadAsStringAsync().Result);
+ Console.ReadKey();
+ */
+
+ // SEND EMAIL
+ /*
// Create the email object first, then add the properties.
- var myMessage = new SendGridMessage();
- myMessage.AddTo("anna@example.com");
- myMessage.From = new MailAddress("john@example.com", "John Smith");
+ var myMessage = new SendGrid.SendGridMessage();
+ myMessage.AddTo("elmer.thomas@sendgrid.com");
+ myMessage.From = new MailAddress("dx@sendgrid.com", "Elmer Thomas");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World! %tag%";
@@ -23,17 +59,16 @@ namespace Example
myMessage.AddSection("%type%", "とんこつ");
SendAsync(myMessage);
+ */
+ }
- Console.ReadLine();
- }
-
- private static async void SendAsync(SendGridMessage message)
+ private static async void SendAsync(SendGrid.SendGridMessage message)
{
// Create credentials, specifying your user name and password.
- var credentials = new NetworkCredential("username", "password");
+ var credentials = new NetworkCredential("<sendgrid_username>", "<sendgrid_password>");
// Create a Web transport for sending email.
- var transportWeb = new Web(credentials);
+ var transportWeb = new SendGrid.Web(credentials);
// Send the email.
try
diff --git a/SendGrid/Example/app.config b/SendGrid/Example/app.config
index e7e5866..f05baaa 100644
--- a/SendGrid/Example/app.config
+++ b/SendGrid/Example/app.config
@@ -18,6 +18,10 @@
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.18.0" newVersion="2.2.18.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> \ No newline at end of file