· 6 years ago · May 03, 2019, 06:22 PM
1
2using System.Net;
3using System.Net.Mail;
4
5[STAThread]
6static void Main(string [] args)
7{
8 String APIKey = "your Mailjet API Key";
9 String SecretKey = "your Mailjet Secret Key";
10 String From = "you@example.com";
11 String To = "recipient@example.com";
12
13 MailMessage msg = new MailMessage ();
14
15 msg.From = new MailAddress (From);
16
17 msg.To.Add (new MailAddress (To));
18
19 msg.Subject = "Your mail from Mailjet";
20 msg.Body = "Your mail from Mailjet, sent by C#.";
21
22 SmtpClient client = new SmtpClient ("in.mailjet.com", 587);
23 client.DeliveryMethod = SmtpDeliveryMethod.Network;
24 client.EnableSsl = true;
25 client.UseDefaultCredentials = false;
26 client.Credentials = new NetworkCredential (APIKey, SecretKey);
27
28 client.Send (msg);
29}