Source Code



Send Email Through Console

  • anonymous
  • Sep 06' 13
  • C Sharp
  • 596
  • 16
  • United States

Here is a listing to send an email from C # using the console:

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net;
 
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("[email protected]");
        MailAddress to = new MailAddress(Console.ReadLine());
 
        Console.WriteLine("[email protected]");
        MailAddress from = new MailAddress(Console.ReadLine());
 
        MailMessage mail = new MailMessage(from, to);
 
        Console.WriteLine("Subject");
        mail.Subject = Console.ReadLine();
 
        Console.WriteLine("Isi Email pasarkode.com");
        mail.Body = Console.ReadLine();
 
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Port = 587;
 
        smtp.Credentials = new NetworkCredential(
            "[email protected]", "password");
        smtp.EnableSsl = true;
        Console.WriteLine("Sending email...");
        smtp.Send(mail);
    }
}

nice read, keep rock 

  • Tags :
comments powered by Disqus

Related Code

Program mencari kpk n buah bilangan

Membuat program bilangan n prima

Piramida angka

Error 945 SQL Server 2008

Looping Leaning Figures

Remarks Script Browser

Creating Specification Page Number

Enter removing Signs In Field (string)

Deleting Log MSSQL Database

Restore and Backup Database MSSQL Using Query



Category