【发布时间】:2013-04-27 05:41:03
【问题描述】:
我正在编写一个 Outlook 2007 加载项,该加载项组成一个商业报价以响应电子邮件查询。我使用 Windows 表单撰写报价单。一切正常,直到我用报价信息回复原始消息。
private void btnSend_Click(object sender, EventArgs e)
{
Outlook.MailItem theMail = ((Outlook._MailItem)quote.mailItem).Reply();
theMail.Subject = "This is the quote";
theMail.Body = <Some html composed elsewhere>;
Outlook.Recipient rcp = theMail.Recipients.Add("Joe Blow");
Outlook.AddressEntry ae = rcp.AddressEntry;
ae.Address = "joe@blow.com";
}
quote.mailItem 是传入的电子邮件请求。当我运行代码时,它会抛出一个执行rcp.AddressEntry 的异常。错误是
'找不到对象'
。 我需要做的是添加和删除收件人,并在发送之前在报价单上设置 CC 和 BCC 字段。收件人可能不在通讯录中。我已经用其他邮件库做到了这一点,它应该很简单,但我似乎为 Outlook 找错了树。
编辑找到了 - 感谢 Dmitry 为我指明了正确的方向。
Outlook.Recipient rcp = theMail.Recipients.Add("joe blow <joe@blow.com>");
rcp.Type = (int)Outlook.OlMailRecipientType.olTo;
【问题讨论】:
-
如果dimitry的回答是正确的,请评分并采纳:)
-
问题不在于 Dmitry 的回答中提供的地址解析,但他确实让我进入了我感谢他的文档的正确区域。
标签: c# outlook ms-office office-interop office-2007