To send emails from Windows platforms, you must use "SMTP authentication".

Below is an example of a C# code (you need to adapt it to your needs):

SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

MailAddress fromAddress = new MailAddress("[email protected]", "From Name");

// You can specify the host name or ipaddress of your server
smtpClient.Host = "mail.yoursite.com"; //you can also specify mail server IP address here

//Default port will be 25
smtpClient.Port = 25;

NetworkCredential info = new NetworkCredential("[email protected]", "smtp-password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = info;

//From address will be given as a MailAddress Object
message.From = fromAddress;

// To address collection of MailAddress
message.To.Add("[email protected]");
message.Subject = "Your subject";

// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("[email protected]")
//message.Bcc.Add("[email protected]");

//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;

// Message body content
string ss_body = "body of email is here";
message.Body = ss_body;

// Send SMTP mail
smtpClient.Send(message);
Cette réponse était-elle pertinente ? 0 Utilisateurs l'ont trouvée utile (0 Votes)