Eml2Pdf / Msg2PdfWinApp / Form1.cs
Code · 35 lines · 744 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35using Eml2MimePart;
using MimePart2Pdf;
using MsgReader.Outlook;
using System.Text;

namespace Msg2PdfWinApp
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Button_Click(object sender, EventArgs e)
		{
			this.button1.Enabled = false;
			this.txtInput.Enabled = false;

			Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

			foreach (var msgFilePath in Directory.GetFiles(this.txtInput.Text, "*.msg"))
			{
				var name = Path.GetFileNameWithoutExtension(msgFilePath);

				var pdfPath = Path.Combine(this.txtPdf.Text, $"{name}.pdf");

				PdfHelper.CreatePdf(msgFilePath, pdfPath, false);
			}

			this.txtInput.Enabled = true;
			this.button1.Enabled = true;
		}
	}
}