如何检查是否已在 WPF 项目中使用 MAPI 发送邮件?
How do I check if a mail has been sent using MAPI in a WPF-Project?
我无法知道用户是否已发送邮件或中止进程。
我正在开发一个 WPF 项目,该项目以 aes-256 加密文件并打开一个 Outlook 弹出窗口,您可以在其中发送加密文件。要解密文件,需要一个代码,该代码通过 SMS 发送给此人,但如果邮件尚未发送,则也不应发送 SMS。问题是我找不到确定它的方法。
try
{
SendMail(zipfile + ".aes");
if (mapi.sent == true)
SendNewSms(); //do not send the SMS if the email has not been sent
else if (mapi.sent == false)
MessageBox.Show("It didn't work!!");
}
catch
{
MessageBox.Show("Error: MAIL");
}
public void SendMail(string attachment)
{
string subject = "";
string body = "";
string attachmentPath = attachment;
mapi.AddAttachment(attachmentPath);
mapi.SendMailPopup(subject, body);
}
MAPI class 具有用于发送邮件的此代码。 "sent" 变量是我自己添加的布尔值
[DllImport("MAPI32.DLL")]
static extern int MAPISendMail(IntPtr sess, IntPtr hwnd, MapiMessage message, int flg, int rsv);
int SendMail(string strSubject, string strBody, int how)
{
MapiMessage msg = new MapiMessage();
msg.subject = strSubject;
msg.noteText = strBody;
msg.recips = GetRecipients(out msg.recipCount);
msg.files = GetAttachments(out msg.fileCount);
m_lastError = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, how,
0);
if (m_lastError > 1)
MessageBox.Show("MAPISendMail failed! " + GetLastError(), "MAPISendMail");
Cleanup(ref msg);
return m_lastError;
}
我的期望是,如果邮件已发送,布尔值将设置为真,否则它将保持为假。
希望写得通俗易懂!
简单 MAPI 不提供任何消息是否已发送的指示。但是,您可以跟踪已发送邮件文件夹的更改。将项目添加到文件夹后,您的消息就已发送。
在 Outlook 对象模型中,您可以找到 MailItem.Sent 属性 其中 returns 一个布尔值,指示是否已发送邮件。
我无法知道用户是否已发送邮件或中止进程。
我正在开发一个 WPF 项目,该项目以 aes-256 加密文件并打开一个 Outlook 弹出窗口,您可以在其中发送加密文件。要解密文件,需要一个代码,该代码通过 SMS 发送给此人,但如果邮件尚未发送,则也不应发送 SMS。问题是我找不到确定它的方法。
try
{
SendMail(zipfile + ".aes");
if (mapi.sent == true)
SendNewSms(); //do not send the SMS if the email has not been sent
else if (mapi.sent == false)
MessageBox.Show("It didn't work!!");
}
catch
{
MessageBox.Show("Error: MAIL");
}
public void SendMail(string attachment)
{
string subject = "";
string body = "";
string attachmentPath = attachment;
mapi.AddAttachment(attachmentPath);
mapi.SendMailPopup(subject, body);
}
MAPI class 具有用于发送邮件的此代码。 "sent" 变量是我自己添加的布尔值
[DllImport("MAPI32.DLL")]
static extern int MAPISendMail(IntPtr sess, IntPtr hwnd, MapiMessage message, int flg, int rsv);
int SendMail(string strSubject, string strBody, int how)
{
MapiMessage msg = new MapiMessage();
msg.subject = strSubject;
msg.noteText = strBody;
msg.recips = GetRecipients(out msg.recipCount);
msg.files = GetAttachments(out msg.fileCount);
m_lastError = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, how,
0);
if (m_lastError > 1)
MessageBox.Show("MAPISendMail failed! " + GetLastError(), "MAPISendMail");
Cleanup(ref msg);
return m_lastError;
}
我的期望是,如果邮件已发送,布尔值将设置为真,否则它将保持为假。
希望写得通俗易懂!
简单 MAPI 不提供任何消息是否已发送的指示。但是,您可以跟踪已发送邮件文件夹的更改。将项目添加到文件夹后,您的消息就已发送。
在 Outlook 对象模型中,您可以找到 MailItem.Sent 属性 其中 returns 一个布尔值,指示是否已发送邮件。