csharp-sparkpost icon indicating copy to clipboard operation
csharp-sparkpost copied to clipboard

Preview Template Function

Open jkatsiotis opened this issue 8 years ago • 10 comments

Hello,

Any chance of adding the "Preview Template" functionality?

More info on the API: https://developers.sparkpost.com/api/templates.html#templates-preview-post

Thanks, John

jkatsiotis avatar Feb 13 '17 18:02 jkatsiotis

Might as well!

Sorry for the late reply, I didn't get an email notification for this....

darrencauthon avatar Feb 15 '17 13:02 darrencauthon

Hi,

Did you get a chance to add this functionality?

Thanks in advance!

eydelrivero avatar Jan 21 '19 12:01 eydelrivero

@eydelrivero You forked and added this functionality right? How are you including it in your project? I need preview functionality as well, so I would like to incorporate your version into my project rather than the official version.

gregveres avatar Oct 17 '19 13:10 gregveres

@eydelrivero I don't know if you have a better approach for using your branch, but I just used github to download your PR, then I copied the source project into my solution. Is that how you are using it?

Also, do you have some sample code of how you call the preview method? I am a little lost on where you get an instance of a template so that you can call the new preview method.

Thanks

gregveres avatar Oct 17 '19 13:10 gregveres

@eydelrivero nevermind on the sample. Having easier access to the code in VS makes it much easier to figure out how to call this stuff. For anybody who stumbles upon this thread later, here is an example of how to call it:

var sparkPostClient = new SparkPost.Client("sparkpost_api_key");
var preview = sparkPostClient.Templates.Preview("email-template-name", transmission.SubstitutionData);

gregveres avatar Oct 17 '19 13:10 gregveres

Sorry @gregveres for this late response. I totally missed your messages from October. Just as a late confirmation, yes! that is exactly how I use it. You can control which version (draft, published) of the template you want to preview by using the optional draft boolean param on the Template() method. The Template() method returns a Task so it should be awaited. Also, to get the resulting html markup you do preview.Html.

eydelrivero avatar Mar 31 '20 18:03 eydelrivero

@eydelrivero :) better late than never.

I have moved away from SparkPost. I was happy enough with them until they changed their pricing model and the first level that I needed as $80 USD per month. That was too expensive so I switched to SendGrid for $15USD per month for the functionality that I need.

There are pros and cons to sendgrid vs sparkpost, but I think I would recommend sendgrid.

gregveres avatar Mar 31 '20 18:03 gregveres

@gregveres glad to know you are good with SendGrid. I'm thinking about it myself after having some trouble sending from Sparkpost to Microsoft accounts.

eydelrivero avatar Mar 31 '20 18:03 eydelrivero

The one big thing about send grid is that for the $15 per month you don't get a dedicated IP address. That means that your sending reputation is at the whim of over send grid customers. This is something that they could manage but they don't.

I could see that once an IP address gets flagged as being responsible for spam, they could quarantine that IP address for the necessary 30 days and use others in the pool. Then when the IP gets off of the lists, they could put it back in service.

But they don't do that so my reliability has taken a hit going from sparkpost to send grid. However, maybe it hasn't. It could just be that sparkpost wasn't giving me the information that email wasn't getting sent due to that issue. Maybe I was seeing that kind of failure with sparkpost but I just didn't know. I don't know.

Anyway, I can't afford to jump up to the $80 per month level to get a dedicated IP address so I just live with it for now.

gregveres avatar Mar 31 '20 19:03 gregveres

Oh, there is something that I could do. I could build in a web hook that listens for that type of failure and retry. But my architecture isn't setup for that. Once I think I send the email, I delete the email from the database and move on. I would have to have a table of "awaiting status" emails so that I could retry. I just haven't gotten around to it.

gregveres avatar Mar 31 '20 19:03 gregveres