Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net;
- using System.Net.Mail;
- namespace Email
- {
- class Program
- {
- static void Main(string[] args)
- {
- Program obj = new Program();
- obj.SendEmail("Just a Mock Message");
- }
- public void SendEmail(string emailBody)
- {
- MailMessage mail = new MailMessage("FromEmail.com","ToEmail.com");
- mail.Subject = "Testing my Application";
- mail.Body = emailBody;
- SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
- smtp.Credentials = new NetworkCredential()
- {
- UserName = "EmailExample.com",
- Password = "example123"
- };
- smtp.EnableSsl = true;
- smtp.Send(mail);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement