Using statement for Base64UrlEncode

c#, gmail-api

Solution

"Base64UrlEncode" is just a custom function:

private static string Base64UrlEncode(string input) {
    var inputBytes = System.Text.Encoding.UTF8.GetBytes(input);
    // Special "url-safe" base64 encode.
    return Convert.ToBase64String(inputBytes)
      .Replace('+', '-')
      .Replace('/', '_')
      .Replace("=", "");
  }

Problem

I am trying to send an email through code, and I ran into a roadblock. I was working off of this when Base64UrlEncode showed up red. I have the same using statements in my code. ``` using System; using System.IO; using System.Net.Mail; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; using MyCompany.Sample.EmailConnector.Model; using Google.Apis.Auth.OAuth2; using Google.Apis.Gmail.v1; using Google.Apis.Gmail.v1.Data; using Google.Apis.Services; using Google.Apis.Util.Store; ... public static Message createGmailMessage(AE.Net.Mail.MailMessage mailMessage) { var messageString = new StringWriter(); mailMessage.Save(messageString); Message gmailMessage = new Message(); gmailMessage.Raw = Base64UrlEncode(messageString.ToString()); } ``` How do I enable the "Base64UrlEncode"?

Original source