i want to restart Outlook everytime i open the console app , i deploy this app on pc server because no one will handle this when holiday.
Why i want to restart outlook ? because outlook in server pc receive many emails , we have apps to take the attachment and download it everyday. But the problem is sometimes the email is stuck , and we must restart outlook to gain the email that stuck.
I already try some code, and for process.start -> it works that can open outlook, but i cant close the duplicate outlook (the old one)
namespace CloseOpenOutlook
{
class Program
{
static void Main(string[] args)
{
Process process = Process.GetCurrentProcess();
var dupl = Process.GetProcessesByName(process.ProcessName);
foreach (var p in dupl)
{
if (p.ProcessName == "OUTLOOK")
{
p.Kill();
}
}
Process myProcess = Process.Start("OUTLOOK");
}
}
}
Expected result = it will close the old outlook and open the new one
Actual result = it open the new one and not close the old one so it will be 2 Outlooks
I dont know where it goes wrong, already try from many source but still not working