Add project files.
This commit is contained in:
1 parent
1492edd472
commit
1c71c22df7
3 files changed
+75
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
namespace OutlookEmailListener;
|
||||
|
||||
using Outlook = Microsoft.Office.Interop.Outlook;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Outlook.Application outlookApp = new Outlook.Application();
|
||||
Outlook.MAPIFolder inbox = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
|
||||
Outlook.Items items = inbox.Items;
|
||||
items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(OnNewMail);
|
||||
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void OnNewMail(object item)
|
||||
{
|
||||
if (item is Outlook.MailItem mail)
|
||||
{
|
||||
Console.WriteLine("New mail received: {0}", mail.Subject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user