Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Net;
- using System.Net.Mail;
- using System.Web;
- namespace MSPTunisia.Models
- {
- public static class Mailer
- {
- public static int SendEmail(string to, string subject, string body)
- {
- SmtpClient client = new SmtpClient()
- {
- Host = "smtp-mail.outlook.com", // if Gmail use : "smtp.gmail.com"
- Port = 587,
- EnableSsl = true
- };
- client.Credentials = new NetworkCredential(
- "SENDER_EMAIL",
- "SENDER_EMAIL_PASSWORD");
- MailMessage mm = new MailMessage();
- mm.From = new MailAddress("SENDER_EMAIL");
- mm.To.Add(to);
- mm.Subject = subject;
- mm.Body = body;
- client.Send(mm);
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement