Transmitly.ChannelProvider.SendGrid is the convenience package for sending email with Transmitly through Twilio SendGrid.
This is the package most applications should install. It wires together:
Transmitly.ChannelProvider.SendGrid.ConfigurationTransmitly.ChannelProvider.SendGrid.Sdk
Supported channels:
Email
dotnet add package Transmitly.ChannelProvider.SendGridusing Transmitly;
ICommunicationsClient client = new CommunicationsClientBuilder()
.AddSendGridSupport(options =>
{
options.ApiKey = "your-sendgrid-api-key";
})
.AddPipeline("welcome-email", pipeline =>
{
pipeline.AddEmail("welcome@example.com".AsIdentityAddress("Example App"), email =>
{
email.Subject.AddStringTemplate("Welcome to Example App");
email.HtmlBody.AddStringTemplate("<strong>Welcome</strong> to Example App.");
email.TextBody.AddStringTemplate("Welcome to Example App.");
});
})
.BuildClient();
var result = await client.DispatchAsync(
"welcome-email",
"customer@example.com".AsIdentityAddress("Customer"),
new { });AddSendGridSupport(options => ...) accepts SendGridOptions.
Common settings:
ApiKey: your Twilio SendGrid API key.Host: defaults tohttps://api.sendgrid.com.Version: defaults tov3.HttpErrorAsException: forward HTTP failures as exceptions from the underlying client.RequestHeaders,UrlPath,Auth, andReliabilitySettingsfor advanced client configuration.
This package registers SendGrid email extensions through email.SendGrid().
The primary provider-specific setting is TemplateId, which lets you send with a SendGrid dynamic template instead of the channel subject/body content.
using Transmitly;
pipeline.AddEmail("welcome@example.com".AsIdentityAddress("Example App"), email =>
{
email.Subject.AddStringTemplate("Welcome to Example App");
email.TextBody.AddStringTemplate("Welcome to Example App.");
email.SendGrid().TemplateId = "d-0123456789abcdef0123456789abcdef";
});This package registers a SendGrid webhook adaptor that converts SendGrid event webhook payloads into Transmitly DeliveryReport instances.
Because SendGrid uses a static webhook URL per account, the Transmitly request adaptor expects the callback URL to identify the channel and provider. A common pattern is to use a URL such as:
https://your-app.example.com/communications/channel/provider/update?tlyc=Email&tlycp=SendGrid
If you are using the MVC integration packages, point the webhook at your Transmitly delivery-report endpoint and include the same query-string context.
- Transmitly
- Transmitly.ChannelProvider.SendGrid.Configuration
- Transmitly.ChannelProvider.SendGrid.Sdk
Copyright (c) Code Impressions, LLC. This open-source project is sponsored and maintained by Code Impressions and is licensed under the Apache License, Version 2.0.