0
我正在用Visual Studio 2010中的c#.net开发outlook 2010加载项。如何使用c#从当前Outlook电子邮件中嵌入图像?
我想从当前电子邮件(未附加)中将图像嵌入到表单区域中。
如何从Outlook电子邮件中嵌入图像?
我试图从谷歌找出,但他们都展示了如何在电子邮件中嵌入图像。 但我想从Outlook电子邮件获取嵌入式图像。
任何人都可以帮助我吗?
我正在用Visual Studio 2010中的c#.net开发outlook 2010加载项。如何使用c#从当前Outlook电子邮件中嵌入图像?
我想从当前电子邮件(未附加)中将图像嵌入到表单区域中。
如何从Outlook电子邮件中嵌入图像?
我试图从谷歌找出,但他们都展示了如何在电子邮件中嵌入图像。 但我想从Outlook电子邮件获取嵌入式图像。
任何人都可以帮助我吗?
您应该能够使用:Microsoft.Office.Interop.Outlook
。以下是Namespace中的大量商品列表。你可能不得不像附件那样对待它;将其保存到另一个文件夹。然后从那里递归地提取数据。
private void ThisApplication_Startup(object sender, System.EventArgs e)
{
this.NewMail += new Microsoft.Office.Interop.Outlook
.ApplicationEvents_11_NewMailEventHandler(ThisApplication_NewMail);
}
private void ThisApplication_NewMail()
{
Outlook.MAPIFolder inBox = this.ActiveExplorer()
.Session.GetDefaultFolder(Outlook
.OlDefaultFolders.olFolderInbox);
Outlook.Items inBoxItems = inBox.Items;
Outlook.MailItem newEmail = null;
inBoxItems = inBoxItems.Restrict("[Unread] = true");
try
{
foreach (object collectionItem in inBoxItems)
{
newEmail = collectionItem as Outlook.MailItem;
if (newEmail != null)
{
if (newEmail.Attachments.Count > 0)
{
for (int i = 1; i <= newEmail
.Attachments.Count; i++)
{
newEmail.Attachments[i].SaveAsFile
(@"C:\TestFileSave\" +
newEmail.Attachments[i].FileName);
}
}
}
}
}
catch (Exception ex)
{
string errorInfo = (string)ex.Message
.Substring(0, 11);
if (errorInfo == "Cannot save")
{
MessageBox.Show(@"Create Folder C:\TestFileSave");
}
}
}
这会将嵌入或附加项目保存到您选择的目录;那么你可以简单地操作那些你选择的附件。希望至少能让你指出写作方向。
非常感谢Greg。你的代码已经解决了我的问题。谢谢洛特。 – Mausami