Using instruction for Base64UrlEncode
I am trying to send an email using a code and I came across a roadblock. I was working on this when Base64UrlEncode appeared in red. I have the same as 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 "Base64UrlEncode"?
+3
source to share
1 answer
"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("=", "");
}
+6
source to share