title: Code for Encode/Decode QuotedPrintable.
body: <p><strong>This method Encode your text to QuotedPrintable format</strong></p>
  
  <pre><code>public static string EncodeQuotedPrintable(string value)
  {
      if (string.IsNullOrEmpty(value))
          return value;
  
      StringBuilder builder = new StringBuilder();
  
      byte[] bytes = Encoding.UTF8.GetBytes(value);
      foreach (byte v in bytes)
      {
          // The following are not required to be encoded:
          // - Tab (ASCII 9)
          // - Space (ASCII 32)
          // - Characters 33 to 126, except for the equal sign (61).
  
          if ((v == 9) || ((v &gt;= 32) &amp;&amp; (v &lt;= 60)) || ((v &gt;= 62) &amp;&amp; (v &lt;= 126)))
          {
              builder.Append(Convert.ToChar(v));
          }
          else
          {
              builder.Append('=');
              builder.Append(v.ToString("X2"));
          }
      }
  
      char lastChar = builder[builder.Length - 1];
      if (char.IsWhiteSpace(lastChar))
      {
          builder.Remove(builder.Length - 1, 1);
          builder.Append('=');
          builder.Append(((int)lastChar).ToString("X2"));
      }
  
      return builder.ToString();
  }
  </code></pre>
  
  <p><strong>This method Decode your text in QuotedPrintable format to string</strong></p>
  
  <pre><code>public static string DecodeQuotedPrintable(string input, string charSet)
  {
      Encoding enc;
  
      try
      {
          enc = Encoding.GetEncoding(charSet);
      }
      catch
      {
          enc = new UTF8Encoding();
      }
  
      var occurences = new Regex(@"(=[0-9A-Z]{2}){1,}", RegexOptions.Multiline);
      var matches = occurences.Matches(input);
  
      foreach (Match match in matches)
      {
          try
          {
              byte[] b = new byte[match.Groups[0].Value.Length / 3];
              for (int i = 0; i &lt; match.Groups[0].Value.Length / 3; i++)
              {
                  b[i] = byte.Parse(match.Groups[0].Value.Substring(i * 3 + 1, 2), System.Globalization.NumberStyles.AllowHexSpecifier);
              }
              char[] hexChar = enc.GetChars(b);
              input = input.Replace(match.Groups[0].Value, new String(hexChar));
          }
          catch
          { ;}
      }
      input = input.Replace("?=", "").Replace("\r\n", "");
  
      return input;
  }
  </code></pre>