我将带有HTML表格的HTML(MIME)邮件发送到我的电子邮件帐户,现在我正在浏览sample VSTO program。我已点击该特定电子邮件。
我在代码中:
using Outlook = Microsoft.Office.Interop.Outlook;
<snip>
currentExplorer = this.Application.ActiveExplorer();
currentExplorer.SelectionChange += new Outlook
.ExplorerEvents_10_SelectionChangeEventHandler
(CurrentExplorer_Event);
private void CurrentExplorer_Event()
{
<snip>
.
.
.
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem =
(selObject as Outlook.MailItem);
BREAKPOINT-> itemMessage = "The item is an e-mail message." +
" The subject is " + mailItem.Subject + ".";
mailItem.Display(false);
}
当我在立即窗口中查看mailItem
时出现错误:
?mailItem.HTMLBody
error CS1061: 'MailItem' does not contain a definition for 'HTMLBody'
and no extension method 'HTMLBody' accepting a first argument of
type 'MailItem' could be found (are you missing a using directive
or an assembly reference?)
我不明白为什么我会收到错误。
答案 0 :(得分:0)
Try to use the late binding technology (see Type.InvokeMember in .Net) for accessing the property.
Do you run the code on a secondary thread? What event handler do you use for accessing the body?
Anyway, the Outlook object model doesn't provide anythyng for signatures. But you can edit the message body at runtime using VBA macros.
The Outlook object model provides three main ways for working with item bodies:
You can read more about all these ways in the Chapter 17: Working with Item Bodies. It us up to you which way is to choose to deal with the message body.