Nasledujúci kód môžeme použiť aj pre iný SMTP server napr. smtp.azet.sk a port 25 (standardný port pre smtp).
Kód v C# :
using System; using System.Windows.Forms; using System.Net.Mail; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); //nastav emailovu adresu odosielatela mail.From = new MailAddress("your_email_address"); //nastav emailovu adresu prijimatela mail.To.Add("to_address"); mail.Subject = "Projectik.eu"; mail.Body = "Text.Ahoj.Hello.Nazdarek"; //port gmail je 587,standardne pre ine smtp je port 25 SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("username(a)gmail.com", "password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); MessageBox.Show("mail Send"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }