Code Monkey home page Code Monkey logo

csharp-sparkpost's People

Contributors

adamhathcock avatar asherber avatar avigoldman avatar aydrian avatar balexandre avatar bizob2828 avatar coldacid avatar darrencauthon avatar dependabot[bot] avatar ewandennis avatar frankzhangwieswolf avatar jamesoflol avatar jetski5822 avatar kirilsi avatar richleland avatar stefandevo avatar zeuss2011 avatar zythra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csharp-sparkpost's Issues

Exception after sending mail

A few seconds after successfully sending a mail the application crashes with the exception below. It probably has to do with some sort of callback or asynchronous processing that occurs after the mail has been delivered. I have copied and pasted the sample code in the documentation - ie. not trying to do anything fancy.

image

Travis Build

@richleland

Just noticed while reviewing the README.md file that the travis build references ruby-sparkpost.svg instead of CSharp.

Not sure if this is expected or not so filing an issue so someone can take a look.

Here is the line in question:
[![Travis CI](https://travis-ci.org/SparkPost/ruby-sparkpost.svg?branch=master)]

Transmission "Options" class doesn't have the IP_Pool property

It seems the C# SDK is a bit out of sync with the actual API. According to this, the "Options" for sending a transmission should have an "ip_pool" property. Maybe I'm missing something here, but I can't find it. There may be other properties that are missing, this is just the first one that is preventing me from using the SDK.

Cant' send mails, because recipients seems to be empty.

I tried to send an example email, code from https://developers.sparkpost.com/

var transmission = new Transmission();
transmission.Content.From.Email = "[email protected]";
transmission.Content.Subject = "Oh hey!";
transmission.Content.Text = "Testing SparkPost - the world\'s most awesomest email service!";
transmission.Content.Html = "<html><body><p>Testing SparkPost - the world\'s most awesomest email service!</p></body></html>";

var recipient = new Recipient
{
    Address = new Address { Email = "[email protected]" }
};
transmission.Recipients.Add(recipient);

var sparky = new Client("<YOUR API KEY>");
sparky.Transmissions.Send(transmission);

But I always get the error
{ "errors": [ { "message": "required field is missing", "description": "recipients or list_id required", "code": "1400" } ] }
Maybe the recipients won't be serialized correctly?

Domain has been verified.

Is Alive check

Hey - Is there an Is Alive check somewhere? an end point I can ping to check to see if the service is up and kicking with the valid APIKey etc?

Support Async API's

Hi, migrating over from Mandrill (as I'm sure are many users).

Would love to see async non-blocking api's get added to the surface area.

Could not install package 'SparkPost 1.0.0.13918'. with NETFramework

From one of our awesome customers:

im trying to install SparkPost using Nugget Package manager console and the
command: Install-Package SparkPost as the web says. My problem is that
seems that is not compatile with .net framework version 4.5.

"Install-Package : Could not install package 'SparkPost 1.0.0.13918'. You
are trying to install this package into a project that targets
'.NETFramework,Version=v4.5', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author
."

Do you know if there's any package compatible with .net Framework, 4.5

Is Metrics API supported?

I don't see any references to Metrics API. I am checking whether it's supported in this project.

Thanks

Nuget Package v1.0.6 is not working

Installing the latest package does not install the correct Newtonsoft.Json version.

Nuget Package Install output:

PM> Install-Package SparkPost
Attempting to resolve dependency 'Newtonsoft.Json (> 6.0.0)'.
Installing 'Newtonsoft.Json 6.0.1'.
Successfully installed 'Newtonsoft.Json 6.0.1'.
Installing 'SparkPost 1.0.6'.
Successfully installed 'SparkPost 1.0.6'.
Adding 'Newtonsoft.Json 6.0.1' to sparky.
Successfully added 'Newtonsoft.Json 6.0.1' to sparky.
Adding 'SparkPost 1.0.6' to sparky.
Successfully added 'SparkPost 1.0.6' to sparky.

Error if you try to send a Transmission:

An unhandled exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, 
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located 
assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 
0x80131040)

Nothing gets sent, no errors

I have API keys, SPF and DKIM set up, have SparkPost 1.0.7 package from NuGet and I'm using this code to send mail:

            var transmission = new Transmission();
            transmission.Content.From.Email = "[email protected]";
            transmission.Content.From.Name = "xyzInquiry";
            transmission.Content.Subject = "xyzwebsite inquiry form";
            transmission.Content.Text = textContent;
            transmission.Content.Html = htmlContent;
            transmission.Content.ReplyTo = inquiry.Email;

            var recipient = new Recipient
            {
                Address = new Address { Email = CloudConfigurationManager.GetSetting("ContactFormMailbox") }
            };
            transmission.Recipients.Add(recipient);
            var sparkPost = new Client(CloudConfigurationManager.GetSetting("SparkPostApiKey"));
            var result = sparkPost.Transmissions.Send(transmission);

When I send mail, I receive no error yet nothing gets sent. Doing a breakpoint for result variable suggests the following:

Id = 27, Status = RanToCompletion

However I get this when I intentionally throw an exception with the result variable, underneath the send line:

Id = 31, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}" System.Threading.Tasks.Task<SparkPost.SendTransmissionResponse>

Date Encoding Issue

When using the suppression list API call I'm getting a date/time JSON encoding issue.

.Suppressions.List(new SuppressionsQuery { From = DateTime.Today.AddMonths(-1), To = DateTime.Today, Limit = 100 }))

Response: 400 Bad Request.

Content: {"errors":[{"param":"to","message":"to must be in the format YYYY-MM-DDTHH:mm:ssZ","value":"2016-05-27T00:00"},{"param":"from","message":"from must be in the format YYYY-MM-DDTHH:mm:ssZ","value":"2016-04-27T00:00"}]}.

Is this a known issue or some missing config perhaps?

nuget 1.6.0

When I try downloading the 1.6.0 version of sparkpost library via nuget it gets the nupkg file, but it's not actually downloading and referencing the library. I had no problems with the last version I was coding against (1.4.0). Am I missing something?

Enclose Name in double quotes

Name value from transmission.Content.From.Name enclosed in double quotes in the "From" field in the email. It should not be enclosed in double quotes, or should be possibility to switch off these double quotes.

Here is my transmission.Content.From settings:
transmission.Content.From.Name = "Redfoodie";
transmission.Content.From.Email = "[email protected]";

What is appears in email: "From: "Redfoodie" [email protected]"
What I expect: "From: Redfoodie [email protected]"

BCC replace TO

Hi,

The code below should add an email address to TO field, and one to BCC, but the BCC seems to overwrite the TO field.

` var transmission = new Transmission();

        Address emailaddressTo = new Address();
        emailaddressTo.Email = strTO;
        emailaddressTo.Name = strNameToSendEmailTo;

        var listRepientsTo = new Recipient();
        listRepientsTo.Address = emailaddressTo;
        listRepientsTo.Type = RecipientType.To;
        transmission.Recipients.Add(listRepientsTo);

        Address emailaddressBCC = new Address();
        emailaddressBCC.Email = strBCC;
        emailaddressBCC.Name = "Assessment";

        var listRepientsBCC = new Recipient();
        listRepientsBCC.Address = emailaddressBCC;
        listRepientsBCC.Type = RecipientType.BCC;
        transmission.Recipients.Add(listRepientsBCC);

`

Support for CC and BCC

hi,

I think support for CC and BCC should be made available in the api itself, I tried with my code like below

ccList.ForEach(e =>
{
    recipientsList.Add(new SparkPost.Recipient() { Address = new SparkPost.Address() { Email = e, HeaderTo = toAddress } });
 });

transmissionHeaders["CC"] = JsonConvert.SerializeObject(ccList);

but I don't see any CC emails could you provide some additional info on this please..

I followed this doc for cc and bcc
https://support.sparkpost.com/customer/portal/articles/1948014-how-to-add-cc-and-bcc-to-emails

Add interfaces for services

For the sake of dependency injection and mocking for tests by consumers of csharp-sparkpost, the Client and Transmissions classes should have interfaces which they will implement. Likewise any additional classes providing SparkPost API functionality should also have interfaces which they would implement.

Add Update method to RecipientLists.cs

In Reference to #105, Sparkpost has an update method for recipientList. Please add it to the RecipientLists.cs.

 public async Task<RetrieveRecipientListsResponse> Update ( RecipientList recipientList ) 
        {
            var request = new Request {
                Url = $"api/{client.Version}/recipient-lists/"+recipientList.Id+"_?num_rcpt_errors=3",
                Method = "PUT",
                Data = dataMapper.ToDictionary(recipientList)
            };


            var response = await requestSender.Send(request);

... So On

Nuget package does not build for .net 4.5

when i am trying to build my solution, i get this

warning MSB3274: The primary reference "SparkPost" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework.

which is causing build to fail, i see that there is a release for 4.5, but is it updated in nuget repo?

Adding CC & BCC using REST/POST and Template

Hi,

I can't see any documentation regarding adding CC and BCC fields to mails,, while using Transmission REST endpoint and template_id.

All I can see is that to add CC and BCC, 'content' shouldn't contain 'template_id' field in the JSON.

Can someone guide me to it?

I've used SparkPost C# nuget but the delivery rate is not consistent. Some calls get dropped (I can't understand why). So my only resolution is using REST method.

Use SpecFlow to provide integration testing for all API calls

The SpecFlow project has been started. Now it's a matter of writing the specs.

I plan to use my personal account with my personal API key to run these specs. If they work out, I'll hook them to the CI server. The only pain point with this idea is that I'll get a bunch of emails, but... that's ok.

Odd JSON encoding

While working with a user here I received an example JSON output from him. He is running: <package id="SparkPost" version="1.2.0" targetFramework="net46" />

This is the JSON I received:

{
    "Id": null,
    "State": null,
    "Options": {
        "StartTime": null,
        "OpenTracking": true,
        "ClickTracking": true,
        "Transactional": true,
        "Sandbox": null,
        "SkipSuppression": null,
        "InlineCss": null,
        "IpPool": null
    },
    "Recipients": [{
        "Address": {
            "Name": "First lash",
            "Email": "[email protected]",
            "HeaderTo": null
        },
        "ReturnPath": null,
        "Tags": ["AbcDef",
        "blah1",
        "en",
        "False"],
        "Metadata": {

        },
        "SubstitutionData": {

        },
        "Type": 0
    }],
    "ListId": null,
    "CampaignId": "ResetPassword - Development",
    "Description": null,
    "Metadata": {

    },
    "SubstitutionData": {
        "dynamic_html": {
            "content": "\u003c!-- Add so the MTA knows this is an HTML email --\u003e\r\n\r\n\r\n\r\nHi John,\u003cbr /\u003e\u003cbr /\u003e\r\nYou recently requested a link to reset your Ukraine Brides Agency password.\u003cbr/\u003e\u003cbr/\u003e\r\nPlease set a new password by following the link below:\u003cbr/\u003e\u003cbr/\u003e\r\n\u003ca href=\"https://localhost/account/changeresetpassword?userId=2\"\u003eClick to reset your password\u003c/a\u003e\u003cbr/\u003e\u003cbr/\u003e\r\nIf you did not request this link then please simply ignore this email.\u003cbr/\u003e\u003cbr/\u003e\r\nPlease feel free to contact our \u003ca href=\"mailto:[email protected]\"\u003e24/7 support team\u003c/a\u003e if you need any assistance.\u003cbr/\u003e\u003cbr/\u003e\r\n\r\nThank you\u003cbr/\u003e\u003cbr/\u003e\r\n\r\nUkraine Brides Agency\u003cbr/\u003e\r\nFriendships - Relationships - Marriage"
        },
        "subject": "Password reset",
        "can_include_unsubscribe_message": false,
        "email_settings_link": "#"
    },
    "ReturnPath": null,
    "Content": {
        "Html": null,
        "Text": null,
        "Subject": null,
        "From": {
            "Name": "Some Name",
            "Email": "[email protected]",
            "HeaderTo": null
        },
        "ReplyTo": null,
        "Headers": {

        },
        "Attachments": [],
        "InlineImages": [],
        "TemplateId": "notification",
        "UseDraftTemplate": null
    },
    "TotalRecipients": 0,
    "NumGenerated": 0,
    "NumFailedGeneration": 0,
    "NumInvalidRecipients": 0
}

This output threw me for a moment because several fields are not part of the transmission post. For example:

"TotalRecipients": 0,
"NumGenerated": 0,
"NumFailedGeneration": 0,
"NumInvalidRecipients": 0

I am also not used to seeing non-set field in the serialized JSON. It is common to not transmit empty fields. For example this is in the JSON:

"ReturnPath": null,

I don't think this will cause any processing error but it does take a moment to get used to.

One last bit of formatting that was a bit surprising (maybe this should be a separate issue) is all the Unicode in the content like \u003c. The JSON should be serialized as UTF-8 instead of Unicode.

Create New Template C# & AJAX

Always i get the 422 Error Message :(
This is a Model:
public class Templates { public Dictionary<string, object> results { get; set; } }

AJAX:
$.ajax({ url: "/CreateTemplate", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify({ "results": { id: "my-test-1", name: "my test", published: true, description: "my test description", options: { "open_tracking": true, "click_tracking": true, "transactional": true }, content: { "from": { "email": "[email protected]", "name": "foo" }, "subject":"welcome back sir!", "reply_to": "[email protected]", "text": "lorem ipsum", "html": "<b>lorem ipsum</b>", "headers": { "X-Customer-Campaign-ID": "DM_2235_TBULK_4852157_552_2016" } } } }), async: false, cache: false, success: function (response) { console.log(response); } });

The HttpWebRequest Method:

`//results as paramater
var data = JsonConvert.SerializeObject(results);

        HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.sparkpost.com/api/v1/templates");
        myHttpWebRequest.Method = "POST";
        myHttpWebRequest.Headers.Add("Authorization", "2c*****************************");

        byte[] byteArray = Encoding.ASCII.GetBytes(data);

        myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
        myHttpWebRequest.ContentLength = byteArray.Length;

        Stream requestStream = myHttpWebRequest.GetRequestStream();
        requestStream.Write(byteArray, 0, byteArray.Length);
        requestStream.Close();

        HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

        Stream responseStream = myHttpWebResponse.GetResponseStream();

        StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

        string pageContent = myStreamReader.ReadToEnd();

        myStreamReader.Close();
        responseStream.Close();

        myHttpWebResponse.Close();

        return pageContent;`

Please help Me!

RuntimeBinderException

I am receiving a number of RuntimeBinderExceptions upon sending an e-mail via "Transmission.Send(...)":

Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll
Additional information: Newtonsoft.Json.Linq.JObject does not contain a definition for results.
Additional information: Newtonsoft.Json.Linq.JObject does not contain a definition for id.
Additional information: Newtonsoft.Json.Linq.JObject does not contain a definition for total_accepted_recipients.
Additional information: Newtonsoft.Json.Linq.JObject does not contain a definition for total_rejected_recipients.

Additional information: The type Newtonsoft.Json.Linq.JValue cannot be converted to a string implicitely (missing cast?)

I'm using the latest SparkPost version (1.1.1) and Newtonsoft.Json 8.0.3. Despite the exceptions being raised, sending the e-mails works as expected. Any suggestions?

Feature request : transmission with given RFC content

Just wondering if csharp-sparkpost can do transmission with option of "use-draft-template=true" (i.e., send email with given rfc822 content), since I am doing some email relay with relay webhook, it will be much easier to allow to send with raw rfc content. I went through the source code but seems this is not yet included?

There seems exist a java version of this function:
https://www.sparkpost.com/blog/advanced-email-templates/#.VwP8nuIrJMw

Could this be done in the near future?

Feature request: Provide "raw" substitution data

Hi,

Internally in our project we have decoupled the sending and generation of emails for various reasons. This seems to cause us a bit of a headache when we want to use templates for the transmission with the current API though. From what I can find the Transmission class only lets us provide substitution data in a dictionary form. Since we are passing data between different parts of our system, our data is already encoded in a JSON string which is ready for the Sparkpost API. To decode this JSON string, only to have the Transmission class encode it again later on is a huge and unneccesary performance penalty.

Is there any possibility to add an alternative way to provide the substitution data to the Transmission class? Perhaps along the lines of a "raw" property on the Transmission class for providing a string JSON representation that would be selected before the substitution data dictionary. This logic could reside in the DataMapper class where the substitution data is assigned.

public virtual IDictionary<string, object> ToDictionary(Transmission transmission) { }

I'm not sure how to get the final JSON serialization to treat the JSON object as a "raw data" though so it doesn't get embedded in "" during serialization.

List of Template from Api

Hi people,

I'm migrating from mandrill to SparkPost

Does anyone know how to recover my templates from the Api in SparkPost?

In Mandrill there is a method called ListTemplates, but here I can not find anything.

Thank's!!!

Error using Suppressions Retrieve "Cannot convert null to 'bool'"

Looks like there is an error using Suppressions.Retrieve("[email protected]") method when the email is on the suppression list, throwing an error "Cannot convert null to 'bool' because it is a non-nullable value type" , if the email is not in the supression list works fine, everything was working ok one and a half moths ago, probably sparpork changed the data cooming back.

I'm using the library from NuGet package version 1.9.3,
by the way the NuGet package ZIP archive contains unsupported data structures.

Bellow a error trace:
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at SparkPost.Suppressions.ConvertResultsToAListOfSuppressions(Object results)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at SparkPost.Suppressions.c__async2.MoveNext()

Allow use of proxy in RequestSender

Hello,

We're porting some code that we used from Mandrill and so far everything has been a breeze. One issue we've run into is that we need to be able to set the underlying HttpClient in RequestSender to use a proxy

var httpClientHandler = new System.Net.Http.HttpClientHandler
{
     Proxy = WebRequest.GetSystemWebProxy()                
};
var client = new HttpClient(httpClientHandler);

Can you allow a custom HttpClientHandler to be set at the Client or Transmissions level that can be passed through to the RequestSender so we can modify the behavior there in the RequestSender.Send method?

Header problem on Mono

This library worked like a charm under Windows and .NET 4.5, but when trying to run the same app under Mono, it crashed somewhere inside the sending logic with a System.FormatException with this stacktrace:

[System.FormatException]: One of the identified items was in an invalid format.
  at System.Net.Http.Headers.HttpHeaders.AddInternal (System.String name, System.Collections.Generic.IEnumerable`1[T] values, System.Net.Http.Headers.HeaderInfo headerInfo, System.Boolean ignoreInvalid) [0x0004c] in <3dff384e916e4a45850531402c5defd9>:0 
  at System.Net.Http.Headers.HttpHeaders.Add (System.String name, System.Collections.Generic.IEnumerable`1[T] values) [0x0001b] in <3dff384e916e4a45850531402c5defd9>:0 
  at System.Net.Http.Headers.HttpHeaders.Add (System.String name, System.String value) [0x00000] in <3dff384e916e4a45850531402c5defd9>:0 
  at SparkPost.RequestSenders.AsyncRequestSender+<Send>c__async0.MoveNext () [0x00095] in <6b893430194846f1b88010ebc191959b>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0 
  at SparkPost.Transmissions+<Send>c__async0.MoveNext () [0x000c4] in <6b893430194846f1b88010ebc191959b>:0

All I was trying is to do a sparkpostClient.Transmissions.Send(message).Wait();

HTML code in variable

Hi people,

I have a problem when I want replace a value containing html code in a variable of SparkPost.

Example code in C#:
string variable = "Hello<>World";
...
transmission.SubstitutionData["myVariable"] = variable;

Example code in HTML (email):
{{ myVariable }}

Result:
Hello<>World

But I want this result:

Hello
World

Anyone know a solution?

Thanks!!!!

Content.From.Name not serialized

I'm creating a transmission like this:

  var mail = new Transmission();
            mail.Content.From.Email = "[email protected]";
            mail.Content.From.Name = "Tester";
            mail.Content.Subject = subject;
            mail.Content.Text = body;

            mail.Recipients.Add( recipient );

However, the json submitted to the API by the sdk/library only has the email in it, and ignores the mail.Content.From.Name property. => Bug

Get MessageEvents from a Transmission

I send a transmission successfully:

public static void Transmissions_SendTemplateEmail()
{
var transmission = new Transmission();

        transmission.Id = "123456789";
        transmission.CampaignId = "Suscripcion";
        transmission.Content.TemplateId = "end-subscription";
        transmission.Content.From.Email = "[email protected]";
        transmission.Content.Subject = "30 dias para vencimiento de suscripcion";

        transmission.Options.OpenTracking = true;
        transmission.Options.ClickTracking = true;

        transmission.SubstitutionData["email_account"] = "[email protected]";
        transmission.SubstitutionData["expiration_date"] = "En una semana";
        transmission.SubstitutionData["expiration_days"] = 30;

        var recipient = new Recipient
        {
            Address = new Address { Email = "[email protected]" }
        };
        transmission.Recipients.Add(recipient);
        recipient = new Recipient
        {
            Address = new Address { Email = "[email protected]" }
        };
        transmission.Recipients.Add(recipient);

        var client = new Client("MY_API_KEY");
        SendTransmissionResponse respuesta = client.Transmissions.Send(transmission).Result;
        // or client.Transmissions.Send(transmission).Wait();
    }

but, how Iget the MessageEvents of this transmission? I have this code, but I get an error:

public static void Events_Documentation()
{
var client = new Client("MY_API_KEY");

        Transmission transmission = new Transmission();
        transmission.Id = "84345231960713831";

        ListMessageEventsResponse Response = client.MessageEvents.List(transmission).Result;
    }

.netframework 4.5.1

We are using 4.5.1, and found out that spark-post was rolled back to 4.5 3 days ago. Any particular reason for the rolling back? Any projected time the package will be available to 4.5.1 .net solutions?

The nuget package installation returns errors:
install-package : Could not install package 'SparkPost 1.0.0.13918'. You are trying to install this package into a project
that targets '.NETFramework,Version=v4.5.1', but the package does not contain any assembly references or content files
that are compatible with that framework. For more information, contact the package author

Sub Accounts

I need the ability to work with subaccounts. I realize that you can do it now with the custom settings on the client, but it would be nice if it could be integrated.

I am happy to do the changes and submit a PR if this is not already in the works.

Feature: Message Events API support

Requirements:
Reading bounces via Message Events API.
Simple query support (search for message event data by event type and date range).
Results paging support (results per page, page number query parameters).

This feature is already under development.
I will also try to include support for all other event types and all query parameters for Message Events API.
I will create a Pull Request when it is finished and fully tested.

Emails not sent, no error

Hi,

I have version 1.1.0 (April 12th), although I see version 1.0.2.22938 in the properties.
I have copied the example and added some changes for my requirements and emails are not being sent out. I also do not get an error. Anyone has encountered this problem or have an idea?

public void SendEmail(string toEmail, string toName, string subject, string body, string fromName = null, string replyTo = null, Guid trackingId = default(Guid))
{
try
{

            if (!System.Diagnostics.Debugger.IsAttached)
            {
                var transmission = new Transmission();
                transmission.Content.From.Email = replyTo ?? "[email protected]";
                transmission.Content.From.Name = fromName ?? "test";
                transmission.Content.Subject = subject;
                transmission.Content.Html = body;
                transmission.Options.OpenTracking = true;

                var recipient = new Recipient
                {
                    Address = new Address { Email = toEmail , Name = toName }
                };
                transmission.Recipients.Add(recipient);

                if (!string.IsNullOrEmpty(replyTo))
                    transmission.Content.ReplyTo = replyTo;

                if (trackingId != Guid.Empty)
                    transmission.Metadata = new Dictionary<string, object> { { "TrackingId", trackingId.ToString() }, { "UserName", toName } };


                //client.Transmissions.Send(transmission).Wait();

                Task result = SendTransmission(transmission);
            }

        }
        catch (Exception ex)
        {
            LogHandler.Error(ex);
        }
    }

    private async Task SendTransmission(Transmission transmission)
    {
        client = new Client(key);
        await client.Transmissions.Send(transmission);            
    }

data is sent as string and not boolean values

As an example for the Options property, the serialized version is:

"{\"content\":{\"template_id\":\"amazon-giftcard\"},\"options\":{\"open_tracking\":\"true\",\"click_tracking\":\"true\",\"transactional\":\"true\",\"sandbox\":\"false\",\"skip_suppression\":\"false\"},\"substitution_data\":{\"code\":\"ABC-123-4567890\",\"amount\":\"$10.00\",\"expiry\":\"12/31/2018\"},\"recipients\":[{\"address\":{\"email\":\"[email protected]\"}},{\"address\":{\"email\":\"[email protected]\",\"header_to\":\"[email protected]\"}}]}"

and the boolean values should be true instead of "true"

This will throw an error saying:

{ 
  "errors": [ 
    { 
      "message": "invalid data format\/type", 
      "description": "field 'options.open_tracking' is of type 'string', but needs to be of type 'boolean'", "code": "1300" 
    } 
    ] 
}

The issue for the serialization of the Options is in the DataMapper as it's returned a string and not a boolean value.

I'll add a pull request for this.

Defining SubstitutionData all in capital letters is not working

Actually, I'm not sure if this is a bug or a rule in your system, but defining SubstitutionData in capital is not working and sends email with no SubstitutionData data.
transmission.SubstitutionData.Add("NAME", "a-name");
And in Template markup:
<div>{{NAME}}</div>
Changing both in lower case (name) makes things working.

SparkPost-API 1.1.0 Sending Transmission Fails

I have updated the SparkPost-API to version 1.1.0 and receive the following exception when sending a transmission:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040)

I'm using Newtonsoft.Json version 8.0.3. Any help appreciated.

MessageEvents quering Issue

I have an error calling the next method:

Error catched: One or multiple errors have occurred.

public void Events()
{
var client = new Client("MY_API_KEY");

        var query = new MessageEventsQuery();
        query.Recipients = new List<string>() { "[email protected]" };
        query.TransmissionIds = new List<string>(){ "00000000000000000" };
        query.From = DateTime.Parse("2016-01-01T00:00");
        query.To = DateTime.Now;
        query.Page = 25;
        query.PerPage = 100;
        try
        {
            ListMessageEventsResponse Response = client.MessageEvents.List(query).Result;
        }catch(Exception e)
        {

        }

}

can help me somebody?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.