-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeController.cs
74 lines (60 loc) · 2.1 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EmailHeader.Models;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using Aspose.Email.Mapi;
using System.Data;
namespace EmailHeader.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
string SourceFilePath = "D:\\Input.msg";
//Load the Message File
SourceFilePath = @"/Users/mudassir/Documents/Email/Messages.msg";
//Reading Email Msg file
MapiMessage msg = MapiMessage.FromFile(SourceFilePath);
//Reading keys
var allKeys = msg.Headers.AllKeys;
// Generate rows and cells.
int numRows = msg.Headers.Count() + 1;
DataTable dt = new DataTable();
dt.Columns.Add("HeaderName");
dt.Columns.Add("Value");
//Iterating all Message headers and populating in table
for (int rowNum = 1; rowNum < numRows; rowNum++)
{
DataRow dRow = dt.NewRow();
dRow["HeaderName"] = allKeys[rowNum - 1].ToString();
dRow["Value"] = msg.Headers[allKeys[rowNum - 1]].ToString();
dt.Rows.Add(dRow);
}
return View(dt);
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}