亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將電子郵件另存為 .eml 并包含原始 email.body

將電子郵件另存為 .eml 并包含原始 email.body

C#
守著星空守著你 2023-09-16 17:17:41
我使用以下代碼保存我的Emailusing api。EWS但是,當我打開保存的.eml格式時.mht,它是帶格式的全文<tags>。有沒有辦法保存 的原始HTML格式email.Body和原始外觀?private static void saveEmailAsEML(EmailMessage email){    {        string to = "[email protected]";        string from = "[email protected]";        string subject = "test subject";        string body = email.Body.();        string emailDir = @"C:\\Temp\\Email";        string msgName = @"email.eml";        Console.WriteLine("Saving e-mail...");        using (var client = new SmtpClient())        {            MailMessage msg = new MailMessage(from, to, subject, body);            client.UseDefaultCredentials = true;            client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;            client.PickupDirectoryLocation = emailDir;            try            {                client.Send(msg);            }            catch (Exception ex)            {                Console.WriteLine("Exception caught: {0}",                ex.ToString());                Console.ReadLine();                System.Environment.Exit(-1);            }        }        var defaultMsgPath = new DirectoryInfo(emailDir).GetFiles()          .OrderByDescending(f => f.LastWriteTime)          .First();        var realMsgPath = Path.Combine(emailDir, msgName);        try        {            File.Move(defaultMsgPath.FullName, realMsgPath);            Console.WriteLine("Message saved.");        }        catch (System.IO.IOException e)        {            Console.WriteLine("File already exists. Overwrite it ? Y / N");            var test = Console.ReadLine();            if (test == "y" || test == "Y")            {                Console.WriteLine("Overwriting existing file...");                File.Delete(realMsgPath);                File.Move(defaultMsgPath.FullName, realMsgPath);                Console.WriteLine("Message saved.");            }
查看完整描述

1 回答

?
寶慕林4294392

TA貢獻2021條經驗 獲得超8個贊

您實際上是從一些屬性重新組裝消息。為什么不獲取整個 MIME 消息(包含所有標頭、附件等)?

查看完整回答
反對 回復 2023-09-16
  • 1 回答
  • 0 關注
  • 116 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號