GEMTI18

______///////

Senin, 29 Juni 2015

Membuat Aplikasi SMTP Email Visual Studio

Aplikasi Smtp Email
Aplikasi Smtp Email
Aplikasi Email Server ini menggunakan socket/port SMPT, Socket SMPT
hanya mampu mengirim Email untuk menerima email, kita memerlukan socket POP3
untuk menerima email.

Daftar Komponen

Rincian Codding

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Text.RegularExpressions;


namespace aplikasi_smtp_email
{

    public partial class Form1 : Form
    {
        bool ssl_status = false;
        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            t_password.PasswordChar = '*';
            cb_akun.Items.AddRange(new object[] { "GMAIL", "YAHOO" });
            t_server.Enabled = false;
            t_port.Enabled = false;
        }

        private void cb_akun_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_akun.SelectedIndex == 0)
            {
                t_server.Text = "smtp.gmail.com";
                t_port.Text = "587";
                ssl_status = true;
                l_user.Text = "@gmail.com";
                l_pengirim.Text = "@gmail.com";
            }

            else if (cb_akun.SelectedIndex == 1)
            {
                t_server.Text = "smtp.yahoo.com";
                t_port.Text = "587";
                ssl_status = true;
                l_user.Text = "yahoo.com";
                l_pengirim.Text = "@yahoo.com";
            }
        }

        private void bt_kirim_Click(object sender, EventArgs e)
        {
            MailMessage pesan = new MailMessage(t_pengirim.Text + l_pengirim, t_penerima.Text, t_subject.Text, t_pesan.Text);
            SmtpClient client_email = new SmtpClient(t_server.Text, Convert.ToInt32(t_port.Text));
            client_email.Credentials = new NetworkCredential(t_user.Text + l_user.Text, t_password.Text);
            client_email.EnableSsl = ssl_status;
            client_email.Send(pesan);
            MessageBox.Show("Email Telah Dikirim", "info");
        }
    }
}


Hasil Smtp Email

INGAT!!
Jika Anda kurang puas atau ingin menambahkan ide
Anda dapat mengkostumnya di Form/View code nya

Untuk keterangan lebih lanjut lihat slide
Download Slide
Download Program


0 komentar:

Posting Komentar

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More