Last active
August 29, 2015 14:10
-
-
Save MaxMelcher/7345d87abe7a1d012d58 to your computer and use it in GitHub Desktop.
Redemption new email event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MailNotifier mailNotifier = new MailNotifier(); | |
mailNotifier.Start(); | |
var t = Task.Factory.StartNew(() => | |
{ | |
while (Console.ReadKey().Key != ConsoleKey.Q) | |
{ | |
} | |
}); | |
t.Wait(); | |
mailNotifier.Stop(); | |
} | |
} | |
public class MailNotifier | |
{ | |
private RDOStore _store; | |
private RDOSession _session; | |
private RDOFolder _folder; | |
private RDOItems _items; | |
public void Start() | |
{ | |
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | |
RedemptionLoader.DllLocation64Bit = path + @"\redemption64.dll"; | |
RedemptionLoader.DllLocation32Bit = path + @"\redemption.dll"; | |
_session = RedemptionLoader.new_RDOSession(); | |
_session.Logon(); | |
_store = _session.Stores.DefaultStore; | |
_folder = _store.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); | |
_items = _folder.Items; | |
Console.WriteLine("Current items: {0}", _items.Count); | |
_items.ItemAdd += OnItemsOnItemAdd; | |
Console.WriteLine("now subscribed to new emails"); | |
} | |
private void OnItemsOnItemAdd(RDOMail item) | |
{ | |
Console.WriteLine("New Mail"); | |
} | |
public void Stop() | |
{ | |
_session.Logoff(); | |
_session = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment