void send_reply(Outlook.MailItem item, HashSet<string> names)
{
Outlook.MailItem eMail = item.Reply();
// want to open an email draft box for user to type in the email's content then return to the program here
eMail.Display();
foreach (string s in names)
{
eMail.To = s;
//MessageBox.Show("this is the guy we are sending to " + item.To);
eMail.Importance = Outlook.OlImportance.olImportanceHigh;
((Outlook._MailItem)eMail).Send();
}
}
想要向给定的邮件发送回复,但只能发送到名称中指定的电子邮件地址。我遇到的问题是当我打电话给电子邮件时。Display((它最多只显示半秒钟,然后草稿自动关闭,我会给每个人发一封空白回复电子邮件。
有人有什么建议吗?
Display()
函数会立即返回,并使要发送的消息为空。
您可以通过将true
传递给函数来等待:
//...
Outlook.MailItem eMail = item.Reply();
eMail.Display(true); // <-- here
//...
这将使窗口模态化,并等待用户关闭它
也许你还必须检查用户是否在没有文本的情况下关闭了它,或者是否打算撤消操作。。。
为此,您可以检查消息状态或为Close
(和Send
(事件中的一个(或两个(注册一个处理程序。