Sumber Kode

Send Email Through Console

  • anonymous
  • Sep 06' 13
  • C Sharp
  • 896
  • 18
  • 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("emailtujuan@domain.com");
        MailAddress to = new MailAddress(Console.ReadLine());
 
        Console.WriteLine("emaildari@domain.com");
        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(
            "username@domain.com", "password");
        smtp.EnableSsl = true;
        Console.WriteLine("Sending email...");
        smtp.Send(mail);
    }
}

nice read, keep rock 

Share

  • Tags :
comments powered by Disqus

Kode Terkait

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



Kategori