我正在構建一個Outlook 2010插件,將它與一些商業軟件集成在一起,並且已經制作了一個自定義ItemSend事件,並使用jason從backened應用了我自己的web服務。我可以將郵件項目保存爲.msg文件(在用戶臨時文件夾中)。但是當我嘗試打開它時問題是,然後Outlook打開它作爲一個消息仍然組成,用戶可以很容易地再次單擊發送按鈕。有沒有辦法來標記Outlook.MailItem已被髮送之前,它被保存?
有沒有一種方法來標誌,它被保存前的項目已被送往所以當事實後打開它打開作爲電子郵件讀取,而不是在構圖電子郵件?
我我分享我的代碼下面請指導我通過這個
void Application_ItemSend(object Item, ref bool Cancel)
{
this.passwordpopUpObj = new Forms.PasswordInputPopUp();
passwordpopUpObj.ShowDialog();
passwordpopUpObj.StartPosition = FormStartPosition.CenterParent;
Outlook.MailItem mail = Item as Outlook.MailItem;
if (passwordpopUpObj.textBox1.Text != "")
{
Cancel = true;
BussinessClass cs = new BussinessClass();
string msg = cs.ServerCallSendMail(mail.Subject, mail.To, mail.CC, attachcount, passwordpopUpObj.textBox1.Text);
if (msg == "Success")
{
mail.SaveAs(@"E:\Plugin.net\EmailCipherPlugin\EmailCipherPlugin\Mails" + "\\" + "file3" + @".msg");
MessageBox.Show("Mail Send SuccessFully through Plugin");
mailItem = Item as Outlook.MailItem;
Cancel = true;
foreach (Outlook.Store store in OutlookObject.Session.Stores)
{
if (store.DisplayName == "Email Cipher")
{
Outlook.MAPIFolder pstRootFolder = store.GetRootFolder();
foreach (Folder folder in pstRootFolder.Folders)
{
MessageBox.Show(store.FilePath + folder.FolderPath);
if (folder.Name == "Email cipher Sent")
{
MessageBox.Show(Directory.Exists(@"E:\Plugin.net\EmailCipherPlugin\EmailCipherPlugin\Mails").ToString());
mail.SaveAs(@"E:\Plugin.net\EmailCipherPlugin\EmailCipherPlugin\Mails" + "\\" + "file3" + @".msg", Outlook.OlSaveAsType.olMSG);
}
}
}
}
}
//
else
{
Cancel = true;
MessageBox.Show("Mail Cannot be sent through plugin");
}
}
else
{
MessageBox.Show("mail Send Normally");
Cancel = false;
mail.Categories = "Sent";
mail.SaveAs(@"E:\Plugin.net\EmailCipherPlugin\EmailCipherPlugin\Mails" + "\\" + "outlookfile" + @".msg", Outlook.OlSaveAsType.olMSG);
}
}
如果你可以複製幾乎已經在這裏http://stackoverflow.com/questions/8799622/set-a-mailitem-as-sent-before-calling-saveas-in-outlook提出確切的問題-addin-with-c-sharp?rq = 1,爲什麼你不能使用答案? – AsheraH