<commit_before>This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-sharp/issues) or make a pull request for any use cases you would like us to document here. Thank you!

# Table of Contents

* [Transactional Templates](#transactional_templates)

<a name="transactional_templates"></a>
# Transactional Templates

For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.

Template ID (replace with your own):

```text
13b8f94f-bcae-4ec6-b752-70d6cb59f932
```

Email Subject:

```text
<%subject%><commit_msg>Add attachment sample code<commit_after>This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-sharp/issues) or make a pull request for any use cases you would like us to document here. Thank you!

# Table of Contents

* [Attachments](#attachments)
* [Transactional Templates](#transactional_templates)

<a name="attachments"></a>
# Attachments

```csharp
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Threading.Tasks;
using System.IO;

namespace Example
{
	internal class Example
	{
		private static void Main()
		{
			Execute().Wait();
		}

		static async Task Execute()
		{
			var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
			var client = new SendGridClient(apiKey);
			var from = new EmailAddress("<EMAIL>");
			var subject = "Subject";
			var to = new EmailAddress("<EMAIL>");
			var body = "Email Body";
			var msg = MailHelper.CreateSingleEmail(from, to, subject, body, "");
			var bytes = File.ReadAllBytes("/Users/username/file.txt");
			var file = Convert.ToBase64String(bytes);
			msg.AddAttachment("file.txt", file);
			var response = await client.SendEmailAsync(msg);
		}
	}
}
```

<a name="transactional_templates"></a>
# Transactional Templates

For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.

Template ID (replace with your own):

```text
13b8f94f-bcae-4ec6-b752-70d6cb59f932
```

Email Subject:

```text
<%subject%>
{'fraction_non_alphanumeric': 0.11470461405778352, 'fraction_numerical': 0.016386373436826217, 'mean_word_length': 5.105263157894737, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2790205', 'n_tokens_mistral': 754, 'n_tokens_neox': 689, 'n_words': 213}