翻譯|行業(yè)資訊|編輯:胡濤|2024-05-13 11:07:46.537|閱讀 97 次
概述:本文將使 C# 開(kāi)發(fā)人員能夠以編程方式將EML或MSG轉(zhuǎn)換為其他流行的文件格式
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
本文將使 C# 開(kāi)發(fā)人員能夠以編程方式將EML或MSG轉(zhuǎn)換為其他流行的文件格式。Aspose.Email 提供了類(lèi)和方法以及在線(xiàn) 電子郵件轉(zhuǎn)換器工具,可將 EML無(wú)縫轉(zhuǎn)換為PNG 。如果不安裝第三方軟件,則無(wú)法打開(kāi) EML/MSG 文件。因此,將 EML/MSG 轉(zhuǎn)換為 PNG 和JPG等圖像文件格式將允許您輕松查看這些文件。因此,在本指南中,我們將通過(guò)一段代碼片段來(lái)使用C#構(gòu)建電子郵件轉(zhuǎn)換軟件。在繼續(xù)之前,請(qǐng)確保您有源EML和MSG文件來(lái)實(shí)現(xiàn)該功能。
Aspose.Email 是用于輕松的開(kāi)發(fā) email 功能的應(yīng)用程序的一組控件,基于 ASP.NET 的Web應(yīng)用、Web服務(wù)和Windows 應(yīng)用。支持 Outlook PST, EML, MSG, and MHT 格式. 允許開(kāi)發(fā)者直接與 SMTP, POP, FTP, 和 MS Exchange 服務(wù)器進(jìn)行工作。支持郵件合并、行事歷、定制郵件標(biāo)題和內(nèi)容、嵌入文件等,Aspose API支持流行文件格式處理,并允許將各類(lèi)文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
要安裝此企業(yè)級(jí) .NET 庫(kù),請(qǐng)?jiān)贜uGet包管理器中運(yùn)行以下命令或在此處下載 DLL 文件。
Install-Package Aspose.Email
除了Aspose.Email for .NET之外,您還需要安裝Aspose.Words for .NET API。
Install-Package Aspose.Words
Aspose.Email for .NET為開(kāi)發(fā)人員提供了完整的安裝指南。此外,安裝需要幾秒鐘,您就可以開(kāi)始使用 API 將EML 轉(zhuǎn)換為 PNG 或 MSG 轉(zhuǎn)換為 PNG。
現(xiàn)在,我們可以編寫(xiě)一個(gè)代碼示例,以編程方式用 C# 構(gòu)建電子郵件轉(zhuǎn)換器工具。
以下步驟展示了如何構(gòu)建電子郵件轉(zhuǎn)換軟件以將 EML 轉(zhuǎn)換為 PNG:
以下代碼片段在 C# 中將 EML 轉(zhuǎn)換為 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); } } }
您可以在下圖中看到輸出:
同樣,您可以通過(guò)在上面的代碼片段中進(jìn)行以下更改來(lái)將MSG 轉(zhuǎn)換為 PNG :
以下代碼示例演示了如何在.NET中將MSG轉(zhuǎn)換為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); } } }
免費(fèi)電子郵件轉(zhuǎn)換器 - 現(xiàn)場(chǎng)演示
我們學(xué)習(xí)了如何為 C# 開(kāi)發(fā)人員開(kāi)發(fā)電子郵件轉(zhuǎn)換軟件。這里有一個(gè)在線(xiàn)工具,可以在線(xiàn)將 EML 轉(zhuǎn)換為 PNG。它由Aspose.Email提供支持。此外,此電子郵件轉(zhuǎn)換器工具是基于網(wǎng)絡(luò)的,并具有用戶(hù)友好的界面,您也可以在手機(jī)上使用此電子郵件轉(zhuǎn)換器。最重要的是,它是免費(fèi)的,您在使用它之前不需要進(jìn)行任何訂閱。
我們?cè)诖私Y(jié)束這篇博文,希望本文對(duì)您有所幫助。我們已經(jīng)了解了如何使用Aspose.Email for .NET在 C# 中構(gòu)建電子郵件轉(zhuǎn)換軟件。此外,我們探索了一個(gè)在線(xiàn)電子郵件轉(zhuǎn)換器工具,可以在線(xiàn)將 EML 轉(zhuǎn)換為 PNG。
歡迎下載|體驗(yàn)更多Aspose文檔管理產(chǎn)品
獲取更多信息請(qǐng)咨詢(xún) 或 加入Aspose技術(shù)交流群(761297826)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn