How to read the mail from OutLook Express using UIAutomation in C# 3.0
-
Can any one Help, I am trying to do following step dynamically using UIAutomation in c# 3.0 1)Open Outlook 2)Open Inbox 3)Select first unread email. 4)Open the first unread email. 5)If there are attachements, download the attachements. Select next unread email and do the same as above. I have tried below code.I Can open the outlook Express.But I can't read mail.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows.Automation;
using System.Diagnostics;namespace ConsoleApplicationUI
{
public class ReadMail
{
static void Main(string[] args)
{
ProcessStartInfo psInfo = new ProcessStartInfo(@"C:\Program Files\Outlook Express\msimn.exe");
Process prov = Process.Start(psInfo);
Thread.Sleep(5000);//Read Inbox AutomationElement Inboxstart = null; PropertyCondition Inboxconds = new PropertyCondition(AutomationElement.NameProperty, "Inbox"); Inboxstart = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, Inboxconds); if (Inboxstart != null) { InvokePattern InboxstartInvoke = (InvokePattern)Inboxstart.GetCurrentPattern(InvokePattern.Pattern); InboxstartInvoke.Invoke(); } Console.Read(); } }
}
Thanks, Bruze