Print Friendly and PDF
Write a program that sends an email. Also validate Sender and Receiver Email address.
Write a program that sends an email. Also validate Sender and Receiver Email address.

Mail Client

Solution

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Web;
using System.Net.Mail;

namespace Question7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MailMessage mail = new MailMessage(From.Text, to.Text, subject.Text, richTextBox1.Text);
            SmtpClient client = new SmtpClient(smtp.Text);
            client.Port = 587;
            client.Credentials = new System.Net.NetworkCredential(username.Text, pass.Text);
            client.EnableSsl = true;
            client.Send(mail);
            MessageBox.Show("Your Message Has Been Delivered Successfully");
        }
    }
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: