本文介绍了Base64UrlEncode的using语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过代码发送电子邮件,但遇到了障碍.我正在使用> .我的代码中有相同的using语句.
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());
}
如何启用"Base64UrlEncode"?
How do I enable the "Base64UrlEncode"?
推荐答案
"Base64UrlEncode"只是一个自定义函数:
"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("=", "");
}
这篇关于Base64UrlEncode的using语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!