i want to send os information detail on my email address but my code just show detail on execution and issue is that how can send this detail on my email address
<asp:Button ID="btnSend" Text="Send Mail" runat="server" OnClick="btnSend_Click" />
protected void Page_Load(object sender, EventArgs e)
{
//os information
SelectQuery Sq = new SelectQuery("Win32_OperatingSystem");
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
foreach (ManagementObject mo in osDetailsCollection)
{
Response.Write("Name : " + mo["name"].ToString() + "<br/>");
Response.Write("Version : " + mo["version"].ToString() + "<br/>");
Response.Write("Csname : " + mo["csname"].ToString() + "<br/>");
Response.Write("Boot Device : " + mo["BootDevice"].ToString() + "<br/>");
Response.Write("Build Number : " + mo["BuildNumber"].ToString() + "<br/>");
Response.Write("BuildType : " + mo["BuildType"].ToString() + "<br/>");
Response.Write("Caption : " + mo["Caption"].ToString() + "<br/>");
Response.Write("CodeSet : " + mo["CodeSet"].ToString() + "<br/>");
Response.Write("CountryCode : " + mo["CountryCode"].ToString() + "<br/>");
Response.Write("CreationClassName : " + mo["CreationClassName"].ToString() + "<br/>");
Response.Write("CSCreationClassName : " + mo["CSCreationClassName"].ToString() + "<br/>");
//Response.Write("CSDVersion : " + mo["CSDVersion"].ToString() + "<br/>");
Response.Write("CurrentTimeZone : " + mo["CurrentTimeZone"].ToString() + "<br/>");
Response.Write("DataExecutionPrevention_Available : " + mo["DataExecutionPrevention_Available"].ToString() + "<br/>");
Response.Write("DataExecutionPrevention_32BitApplications : " + mo["DataExecutionPrevention_32BitApplications"].ToString() +
"<br/>");
Response.Write("DataExecutionPrevention_Drivers : " + mo["DataExecutionPrevention_Drivers"].ToString() + "<br/>");
Response.Write("DataExecutionPrevention_SupportPolicy : " + mo["DataExecutionPrevention_SupportPolicy"].ToString() + "<br/>");
Response.Write("Debug : " + mo["Debug"].ToString() + "<br/>");
Response.Write("Description : " + mo["Description"].ToString() + "<br/>");
Response.Write("Distributed : " + mo["Distributed"].ToString() + "<br/>");
Response.Write("EncryptionLevel : " + mo["EncryptionLevel"].ToString() + "<br/>");
Response.Write("ForegroundApplicationBoost : " + mo["ForegroundApplicationBoost"].ToString() + "<br/>");
Response.Write("FreePhysicalMemory : " + mo["FreePhysicalMemory"].ToString() + "<br/>");
Response.Write("FreeSpaceInPagingFiles : " + mo["FreeSpaceInPagingFiles"].ToString() + "<br/>");
Response.Write("FreeVirtualMemory : " + mo["FreeVirtualMemory"].ToString() + "<br/>");
Response.Write("InstallDate : " + mo["InstallDate"].ToString() + "<br/>");
Response.Write("LastBootUpTime : " + mo["LastBootUpTime"].ToString() + "<br/>");
Response.Write("LocalDateTime : " + mo["LocalDateTime"].ToString() + "<br/>");
Response.Write("Locale : " + mo["Locale"].ToString() + "<br/>");
Response.Write("Manufacturer : " + mo["Manufacturer"].ToString() + "<br/>");
Response.Write("MaxNumberOfProcesses : " + mo["MaxNumberOfProcesses"].ToString() + "<br/>");
Response.Write("MaxProcessMemorySize : " + mo["MaxProcessMemorySize"].ToString() + "<br/>");
Response.Write("NumberOfProcesses : " + mo["NumberOfProcesses"].ToString() + "<br/>");
Response.Write("NumberOfUsers : " + mo["NumberOfUsers"].ToString() + "<br/>");
Response.Write("OperatingSystemSKU : " + mo["OperatingSystemSKU"].ToString() + "<br/>");
Response.Write("Organization : " + mo["Organization"].ToString() + "<br/>");
Response.Write("OSArchitecture : " + mo["OSArchitecture"].ToString() + "<br/>");
Response.Write("OSLanguage : " + mo["OSLanguage"].ToString() + "<br/>");
Response.Write("OSType : " + mo["OSType"].ToString() + "<br/>");
//Response.Write("PAEEnabled : " + mo["PAEEnabled"].ToString() + "<br/>");
Response.Write("Primary : " + mo["Primary"].ToString() + "<br/>");
Response.Write("ProductType : " + mo["ProductType"].ToString() + "<br/>");
Response.Write("RegisteredUser : " + mo["RegisteredUser"].ToString() + "<br/>");
Response.Write("SerialNumber : " + mo["SerialNumber"].ToString() + "<br/>");
Response.Write("ServicePackMajorVersion : " + mo["ServicePackMajorVersion"].ToString() + "<br/>");
Response.Write("ServicePackMinorVersion : " + mo["ServicePackMinorVersion"].ToString() + "<br/>");
Response.Write("SizeStoredInPagingFiles : " + mo["SizeStoredInPagingFiles"].ToString() + "<br/>");
Response.Write("Status : " + mo["Status"].ToString() + "<br/>");
Response.Write("SuiteMask : " + mo["SuiteMask"].ToString() + "<br/>");
Response.Write("SystemDevice : " + mo["SystemDevice"].ToString() + "<br/>");
Response.Write("SystemDirectory : " + mo["SystemDirectory"].ToString() + "<br/>");
Response.Write("SystemDrive : " + mo["SystemDrive"].ToString() + "<br/>");
Response.Write("TotalVirtualMemorySize : " + mo["TotalVirtualMemorySize"].ToString() + "<br/>");
Response.Write("TotalVisibleMemorySize : " + mo["TotalVisibleMemorySize"].ToString() + "<br/>");
Response.Write("Version : " + mo["Version"].ToString() + "<br/>");
Response.Write("WindowsDirectory : " + mo["WindowsDirectory"].ToString() + "<br/>");
}
}
protected void btnSend_Click(object sender, EventArgs e)
{
SendHTMLMail();
}
public void SendHTMLMail()
{
StreamReader reader = new StreamReader(Server.MapPath("~/Default.aspx"));
string readFile = reader.ReadToEnd();
//Session["Value"] = "welcome";
//Response.Redirect("~/html.aspx");
string myString = "";
myString = readFile;
myString = myString.Replace("$$Name$$", "M.MunirAhmed");
myString = myString.Replace("$$Class$$", "MSCS ");
myString = myString.Replace("$$CourseCode$$", "EH-101");
myString = myString.Replace("$$ProjectName$$", "Ethical Hacking Project");
MailMessage mail = new MailMessage();
mail.From = new MailAddress("email@gmail.com");
mail.To.Add(new MailAddress("email@gmail.com"));
mail.Subject = "Send Mail with HTML File";
mail.Body = myString.ToString();
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("email@gmail.com", "pswd");
smtp.EnableSsl = true;
smtp.Send(mail);
//lblmsg.Text = "Mail Send .......";
reader.Dispose();
}