如何在发送前将 outlook 邮件对象打开为草稿邮件?
How to open outlook mail object as a draft email before sending?
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();
}
}
想要对给定的邮件项目发送回复,但只发送到名称中指定的电子邮件地址。我遇到的问题是,当我调用 eMail.Display() 时,它最多只显示半秒钟,然后草稿自动关闭,我向姓名中的每个人发送一封空白回复电子邮件。
有人有什么建议吗?
Display()
函数 returns 立即将您的消息发送为空。
您可以通过将 true
传递给函数来等待:
//...
Outlook.MailItem eMail = item.Reply();
eMail.Display(true); // <-- here
//...
这将使 window 模式化并等待用户关闭它。
也许您还必须检查用户是否在没有文本的情况下关闭了它,或者有意撤消操作...
要做到这一点,也许您可以检查消息状态或为 Close
(和 Send
)事件之一(或两者)注册处理程序。
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();
}
}
想要对给定的邮件项目发送回复,但只发送到名称中指定的电子邮件地址。我遇到的问题是,当我调用 eMail.Display() 时,它最多只显示半秒钟,然后草稿自动关闭,我向姓名中的每个人发送一封空白回复电子邮件。
有人有什么建议吗?
Display()
函数 returns 立即将您的消息发送为空。
您可以通过将 true
传递给函数来等待:
//...
Outlook.MailItem eMail = item.Reply();
eMail.Display(true); // <-- here
//...
这将使 window 模式化并等待用户关闭它。
也许您还必须检查用户是否在没有文本的情况下关闭了它,或者有意撤消操作...
要做到这一点,也许您可以检查消息状态或为 Close
(和 Send
)事件之一(或两者)注册处理程序。