0% found this document useful (0 votes)
52 views1 page

How To Send An Email With C

This document provides code to send an email with C# by creating a MailMessage object with the from, to, subject, and body properties set. It then creates a SmtpClient, sets the credentials using a NetworkCredential with the gmail username and password, enables SSL, and sends the message. The code is contained within a Windows Forms project and button click handler to trigger the email send.

Uploaded by

jeannzonzidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views1 page

How To Send An Email With C

This document provides code to send an email with C# by creating a MailMessage object with the from, to, subject, and body properties set. It then creates a SmtpClient, sets the credentials using a NetworkCredential with the gmail username and password, enables SSL, and sends the message. The code is contained within a Windows Forms project and button click handler to trigger the email send.

Uploaded by

jeannzonzidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

How To send an email with C#

Project Source Code :



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;

namespace email
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void send_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage("your gmail
mail",textTo.Text,textSubject.Text,textmail.Text);
msg.IsBodyHtml = true;
SmtpClient sc = new SmtpClient("smtp.gmail.com",587);
sc.UseDefaultCredentials = false;
NetworkCredential cre = new NetworkCredential("your gmail mail",textpass.Text);//your
mail password
sc.Credentials = cre;
sc.EnableSsl = true;
sc.Send(msg);
MessageBox.Show("Mail Send");
}

}
}

You might also like