Daniel Tou
New member
- Joined
- Jan 15, 2017
- Messages
- 4
- Programming Experience
- Beginner
Hi , 
Please help me with the exception i get :
"An unhandled exception of type 'System.ArgumentNullException' occurred in System.Core.dll
Additional information: Value cannot be null."
And tell me if i am on the wright track to parse the email body.
Thank you !
 
	
		
			
		
		
	
				
			Please help me with the exception i get :
"An unhandled exception of type 'System.ArgumentNullException' occurred in System.Core.dll
Additional information: Value cannot be null."
And tell me if i am on the wright track to parse the email body.
Thank you !
static void Main(string[] args)
        {
            Microsoft.Office.Interop.Outlook.Application app = null;
            Microsoft.Office.Interop.Outlook._NameSpace ns = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;
            Excel.Application oApp;
            Excel.Workbook oWB;
            Excel.Worksheet oSheet;
            app = new Microsoft.Office.Interop.Outlook.Application();
            ns = app.GetNamespace("MAPI");
            ns.Logon("daniel.tou@XXXXX", "XXXXXX", false, true);
            inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            subFolder = inboxFolder.Folders["Test"]; //folder.Folders[1]; also works
            oApp = new Excel.Application();
            oWB = oApp.Workbooks.Add();
            oSheet = (Excel.Worksheet)oWB.Worksheets.get_Item(1);
            MailItem mailItem = app.CreateItem(OlItemType.olMailItem);
            mailItem.HTMLBody = subFolder.ToString();
            HtmlAgilityPack.HtmlDocument emailBody = new HtmlAgilityPack.HtmlDocument();
            emailBody.LoadHtml(mailItem.HTMLBody);
            HtmlAgilityPack.HtmlNode[] nodes = emailBody.DocumentNode.SelectNodes("//td").ToArray();
            foreach (HtmlAgilityPack.HtmlNode item in nodes)
            {
                Console.WriteLine(item.InnerHtml);
            }
			
				Last edited by a moderator: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	 
 
		