日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

c# 收取邮件 解析,C#电子邮件主题解析

發布時間:2025/3/15 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c# 收取邮件 解析,C#电子邮件主题解析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

I'm building a system for reading emails in C#. I've got a problem parsing the subject, a problem which I think is related to encoding.

The subject I'm reading is as follows: =?ISO-8859-1?Q?=E6=F8sd=E5f=F8sdf_sdfsdf?=, the original subject sent is ??sd?f?sdf sdfsdf (Norwegian characters in there).

Any ideas how I can change encoding or parse this correctly? So far I've tried to use the C# encoding conversion techniques to encode the subject to utf8, but without any luck.

Here is one of the solutions I tried:

Encoding iso = Encoding.GetEncoding("iso-8859-1");

Encoding utf = Encoding.UTF8;

string decodedSubject =

utf.GetString(Encoding.Convert(utf, iso,

iso.GetBytes(m.Subject.Split('?')[3])));

解決方案

The encoding is called quoted printable.

See the answers to this question.

Adapted from the accepted answer:

public string DecodeQuotedPrintable(string value)

{

Attachment attachment = Attachment.CreateAttachmentFromString("", value);

return attachment.Name;

}

When passed the string =?ISO-8859-1?Q?=E6=F8sd=E5f=F8sdf_sdfsdf?= this returns "??sd?f?sdf_sdfsdf".

總結

以上是生活随笔為你收集整理的c# 收取邮件 解析,C#电子邮件主题解析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。