i need suggestions to help me implement a function to open multiple .msg files in outlook from a winform application without opening multiple outlook windows.
i tried Process.Start but it opened multiple outlook windows which is not the desired behavior that i'm looking at.
Manpreet SinghPosted Mar 4, 2015, 5:39 PM
It is taking file from the local, Can you please show the code where you are providing the path.
Cheers !
Manpreet
Zen Liu ZhanhongPosted Feb 23, 2015, 1:55 AM
{"We can't open 'C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\Windows\\INetCache\\IE\\DNUW6R2R\\_NE...'. It's possible the file is already open, or you don't have permission to open it.\n\nTo check your permissions, right-click the file folder, then click Properties."}
which is weird as the url i provide is nothing like what is mentioned above. it goes something like https://sharepointsite.com/marketing/market.msg
Keyur PatelPosted Feb 23, 2015, 12:36 AM
You could do this using VSTO(Visual Studio Tool Office) instead of process.start because process.start method open outlook process.exe every time. So, it's open multiple outlook windows which it not the right behavior.
You can subscribe mailItem.Open event from your window application and open every in same outlook window.
Just Sample , it is not fulfill your requirement.
using Microsoft.Office.Interop.Outlook; using System.Windows.Forms; namespace SampleAddins { public partial class ThisAddIn { MailItem _mailItem = null; private void ThisAddIn_Startup(object sender, System.EventArgs e) { this.Application.ItemLoad += new ApplicationEvents_11_ItemLoadEventHandler(Application_ItemLoad); } void Application_ItemLoad(object Item) { if (Item is MailItem) { try { MailItem mailItem = Item as MailItem; mailItem.Open += new ItemEvents_10_OpenEventHandler(mailItem_Open); _mailItem = mailItem; } catch (System.Exception ex) { MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } void mailItem_Open(ref bool Cancel) { if (_mailItem.Subject.Contains("C-Sharp") == true) { // This requires "Send As" privileges at the AD: _mailItem.SentOnBehalfOfName = "[email protected]"; } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }