title: Issue with substitution in sendgrid
body: <p>I've to send a mail with substitution using sendgrid.
  I use the following code : </p>
  
  <pre><code>    public async Task SendConfirmationMailAsync(UserCreateViewModel model, string domain, ApplicationUser user)
      {
          string q = _encryption.EncryptText(model.Email + "|" + model.Password, _configuration["Security:EncryptionKey"]);
          string encryptdetexturl = HttpUtility.UrlEncode(q);
          string url = domain + "/Device/RegisterDevice?q=" + encryptdetexturl;
  
  
          Dictionary&lt;string, string&gt; substitution = new Dictionary&lt;string, string&gt;();
          substitution.Add("-indirizzo_email-", url);
  
          await _emailService.SendEmailAsync(user.Email, "d-1201e63adfa04976ba9fc17212172fe9", substitution);
      }
  </code></pre>
  
  <p>that calls</p>
  
  <pre><code>    public async Task SendEmailAsync(ApplicationUser applicationUser, string templateId)
      {
          var apiKey = _configuration["Email:apikey"];
  
          var client = new SendGridClient(apiKey);
  
          var from = new EmailAddress(_configuration["Email:Email"]);
          var to = new EmailAddress(applicationUser.Email);
  
          var substitutions = GetReplacement(applicationUser);
  
          var msg = MailHelper.CreateSingleTemplateEmail(from, to, templateId, null,substitutions);
  
          var response = await client.SendEmailAsync(msg);
  
          Trace.WriteLine(msg.Serialize());
          Trace.WriteLine(response.StatusCode);
          Trace.WriteLine(response.Headers);
      }
  </code></pre>
  
  <p>that calls</p>
  
  <pre><code>    public static SendGridMessage CreateSingleTemplateEmail(
                                                      EmailAddress from,
                                                      EmailAddress to,
                                                      string templateId,
                                                      object dynamicTemplateData,
                                                      Dictionary&lt;string, string&gt; substitutions)
      {
          if (string.IsNullOrWhiteSpace(templateId))
          {
              throw new ArgumentException($"{nameof(templateId)} is required when creating a dynamic template email.", nameof(templateId));
          }
  
          var msg = new SendGridMessage();
          msg.SetFrom(from);
          msg.AddTo(to);
          msg.TemplateId = templateId;
  
          if (dynamicTemplateData != null)
          {
              msg.SetTemplateData(dynamicTemplateData);
          }
  
          if (substitutions != null)
          {
              msg.AddSubstitutions(substitutions);
          }
  
          return msg;
      }
  </code></pre>
  
  <p>The send process alwais fails probably because in the third method I've separated dynamicTemplateData and substitutions. I have to send a message that refers to a templeate stored in sendgrid and and i haven't to pass it to the method.</p>
  
  <p>The Sendgrid error is the following :</p>
  
  <blockquote>
    <p>{"from":{"email":"info@elettrone.com"},"personalizations":[{"to":[{"email":"yocax2@elettrone.com"}],"substitutions":{"-indirizzo_email-":"<a href="https://localhost:44391/Device/RegisterDevice?q=tnGdfw1EojMggP15KY39IWJGE9GkYWOTzMBsungIHrNJm6gzwc1r1zRpMZDH55%2fQ" rel="nofollow noreferrer">https://localhost:44391/Device/RegisterDevice?q=tnGdfw1EojMggP15KY39IWJGE9GkYWOTzMBsungIHrNJm6gzwc1r1zRpMZDH55%2fQ</a>"}}],"template_id":"d-1201e63adfa04976ba9fc17212172fe9"}
    BadRequest
    Server: nginx
    Date: Mon, 23 Sep 2019 18:06:50 GMT
    Connection: keep-alive
    Access-Control-Allow-Origin: <a href="https://sendgrid.api-docs.io" rel="nofollow noreferrer">https://sendgrid.api-docs.io</a>
    Access-Control-Allow-Methods: POST
    Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl
    Access-Control-Max-Age: 600
    X-No-CORS-Reason: <a href="https://sendgrid.com/docs/Classroom/Basics/API/cors.html" rel="nofollow noreferrer">https://sendgrid.com/docs/Classroom/Basics/API/cors.html</a></p>
  </blockquote>
  
  <p>Can anyone help me please?</p>