2016-10-27 64 views
0

我正在構建一個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); 
     } 

} 
+0

如果你可以複製幾乎已經在這裏http://stackoverflow.com/questions/8799622/set-a-mailitem-as-sent-before-calling-saveas-in-outlook提出確切的問題-addin-with-c-sharp?rq = 1,爲什麼你不能使用答案? – AsheraH

回答

0

在擴展MAPI水平,MSGFLAG_UNSENT位可以從PR_MESSAGE_FLAGS財產被刪除的消息僅是之前保存的第一次。此限制僅適用於Outlook文件夾中的郵件,而不適用於獨立MSG文件。

你的具體情況,您可以

  1. 等到郵件被移動到已發送的郵件文件夾並保存的MSG文件形式存在

  2. 如果你想調整的MSG文件保存後,您可以使用擴展MAPI(C++或Delphi只 - OpenIMsgOnIStg /等),也可以使用Redemption(任何語言) - 使用RDOSessionGetMessageFromMsgFile,設置爲RDOMailSent屬性爲true,請致電RDOMailSave

相關問題