c# - 如何在发送前将 Outlook 邮件对象作为草稿电子邮件打开?
问题描述
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()
函数立即返回并使您发送的消息为空。
true
您可以通过传递给函数来等待:
//...
Outlook.MailItem eMail = item.Reply();
eMail.Display(true); // <-- here
//...
这将使窗口模态并等待用户关闭它。
也许您还必须检查用户是否在没有文本的情况下关闭它或打算撤消操作......
为此,您可以检查消息状态或将处理程序注册到一个(或两个)Close
(和Send
)事件。
推荐阅读
- javascript - 无法将 css 动画属性添加到组件
- c++ - Qt WebAssembly 和 QVector 的继承
- python - 处理 CSV 文件中的 JSON 对象并保存到 PySpark DataFrame
- flutter - 无法在颤动中获取子集合以及集合
- apache-nifi - Nifi PutSNS - 大小超过 256KB
- html - 如何在 CSS 中居中和覆盖图像?
- google-chrome-extension - 请求权限后关闭 Chrome 扩展弹出窗口
- c++ - 将元素推回 Std::variant 的向量
- php - 获取所有数组值超过 100 或更多,并获取数组所有值 100 小于
- javascript - tsyringe - 使用重载的构造函数注入依赖项