翻譯|行業資訊|編輯:胡濤|2024-05-13 11:07:46.537|閱讀 97 次
概述:本文將使 C# 開發人員能夠以編程方式將EML或MSG轉換為其他流行的文件格式
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文將使 C# 開發人員能夠以編程方式將EML或MSG轉換為其他流行的文件格式。Aspose.Email 提供了類和方法以及在線 電子郵件轉換器工具,可將 EML無縫轉換為PNG 。如果不安裝第三方軟件,則無法打開 EML/MSG 文件。因此,將 EML/MSG 轉換為 PNG 和JPG等圖像文件格式將允許您輕松查看這些文件。因此,在本指南中,我們將通過一段代碼片段來使用C#構建電子郵件轉換軟件。在繼續之前,請確保您有源EML和MSG文件來實現該功能。
Aspose.Email 是用于輕松的開發 email 功能的應用程序的一組控件,基于 ASP.NET 的Web應用、Web服務和Windows 應用。支持 Outlook PST, EML, MSG, and MHT 格式. 允許開發者直接與 SMTP, POP, FTP, 和 MS Exchange 服務器進行工作。支持郵件合并、行事歷、定制郵件標題和內容、嵌入文件等,Aspose API支持流行文件格式處理,并允許將各類文檔導出或轉換為固定布局文件格式和最常用的圖像/多媒體格式。
要安裝此企業級 .NET 庫,請在NuGet包管理器中運行以下命令或在此處下載 DLL 文件。
Install-Package Aspose.Email
除了Aspose.Email for .NET之外,您還需要安裝Aspose.Words for .NET API。
Install-Package Aspose.Words
Aspose.Email for .NET為開發人員提供了完整的安裝指南。此外,安裝需要幾秒鐘,您就可以開始使用 API 將EML 轉換為 PNG 或 MSG 轉換為 PNG。
現在,我們可以編寫一個代碼示例,以編程方式用 C# 構建電子郵件轉換器工具。
以下步驟展示了如何構建電子郵件轉換軟件以將 EML 轉換為 PNG:
以下代碼片段在 C# 中將 EML 轉換為 PNG。
using Aspose.Email; using Aspose.Words; namespace Aspose.Email { class EMLtoPNG { // Email conversion software for C# Developers - EML to PNG static void Main(string[] args) { string dataDir = "/sample-files/"; // Create an object of the EmlLoadOptions class that will be used to load MailMessage from EML format. EmlLoadOptions emlLoadOptions = new EmlLoadOptions(); // Set a value of RemoveSignature property to indicate whether signature will be removed while loading. emlLoadOptions.RemoveSignature = false; // Invoke the Load method of the MailMessage class to load the source eml file. MailMessage msg = MailMessage.Load(dataDir + "sample.eml", emlLoadOptions); // Set the Sensitivity of the message. msg.Sensitivity = MailSensitivity.Normal; // Set the Priority of the message. msg.Priority = MailPriority.High; // Instantiate an instance of the MemoryStream class. MemoryStream msgStream = new MemoryStream(); // Convert EML to MHTML and save to stream by calling the Save method. msg.Save(msgStream, SaveOptions.DefaultMhtml); // Invoke the Position property and set the current position within the stream. msgStream.Position = 0; // Initialize an instance of the Document class with the MHTML stream. Document msgDocument = new Document(msgStream); // Save the document as PNG image by calling the Save method. msgDocument.Save(dataDir + "Outlook-Aspose_out.png", SaveFormat.Png); } } }
您可以在下圖中看到輸出:
同樣,您可以通過在上面的代碼片段中進行以下更改來將MSG 轉換為 PNG :
以下代碼示例演示了如何在.NET中將MSG轉換為PNG:
using Aspose.Email; using Aspose.Words; namespace Aspose.Email { class MSGtoPNG { // Email conversion software for C# Developers - MSG to PNG static void Main(string[] args) { string dataDir = "/sample-files/"; // Create an object of the MsgLoadOptions class that will be used to load MailMessage from MSG format. MsgLoadOptions msgLoadOptions = new MsgLoadOptions(); // Set a value of RemoveSignature property to indicate whether signature will be removed while loading. msgLoadOptions.RemoveSignature = false; // Invoke the Load method of the MailMessage class to load the source MSG file. MailMessage msg = MailMessage.Load(dataDir + "sample.msg", msgLoadOptions); // Set the Sensitivity of the message. msg.Sensitivity = MailSensitivity.Normal; // Set the Priority of the message. msg.Priority = MailPriority.High; // Instantiate an instance of the MemoryStream class. MemoryStream msgStream = new MemoryStream(); // Convert MSG to MHTML and save to stream by calling the Save method. msg.Save(msgStream, SaveOptions.DefaultMhtml); // Invoke the Position property and set the current position within the stream. msgStream.Position = 0; // Initialize an instance of the Document class with the MHTML stream. Document msgDocument = new Document(msgStream); // Save the document as PNG image by calling the Save method. msgDocument.Save(dataDir + "Outlook-Aspose_out.png", SaveFormat.Png); } } }
免費電子郵件轉換器 - 現場演示
我們學習了如何為 C# 開發人員開發電子郵件轉換軟件。這里有一個在線工具,可以在線將 EML 轉換為 PNG。它由Aspose.Email提供支持。此外,此電子郵件轉換器工具是基于網絡的,并具有用戶友好的界面,您也可以在手機上使用此電子郵件轉換器。最重要的是,它是免費的,您在使用它之前不需要進行任何訂閱。
我們在此結束這篇博文,希望本文對您有所幫助。我們已經了解了如何使用Aspose.Email for .NET在 C# 中構建電子郵件轉換軟件。此外,我們探索了一個在線電子郵件轉換器工具,可以在線將 EML 轉換為 PNG。
歡迎下載|體驗更多Aspose文檔管理產品
獲取更多信息請咨詢 或 加入Aspose技術交流群(761297826)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn