using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
IDataObject iData = Clipboard.GetDataObject();
MemoryStream ms = (MemoryStream)iData.GetData("Csv");
if (ms != null)
{
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);
string EntryId = System.Text.Encoding.Unicode.GetString(buffer);
Process[] ps = Process.GetProcessesByName("OUTLOOK");
Outlook.Application olApp = null;
if (ps.Length > 0)
{
olApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
}
else
{
olApp = new Outlook.Application();
}
var item = olApp.Session.GetItemFromID(EntryId);
item.SaveAs("test.msg", Outlook.OlSaveAsType.olMSGUnicode);
}
else
{
MessageBox.Show("NO");
}
}
}
}
欢迎访问《 许阳的红泥屋 》

本文介绍了一个实用工具,该工具能够从剪贴板读取CSV格式的数据,并利用这些数据从当前运行的Outlook实例中查找并导出指定的邮件为MSG文件格式。这一过程涉及多个步骤和技术要点,包括但不限于使用.NET Framework进行开发、内存流操作、进程管理及跨进程调用。
3600

被折叠的 条评论
为什么被折叠?



