Using statement for Base64UrlEncode [closed]

[亡魂溺海] 提交于 2019-12-07 09:55:21

问题


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"?


回答1:


"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("=", "");
  }


来源:https://stackoverflow.com/questions/30246497/using-statement-for-base64urlencode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!