Send an e-mail with C#

<p class="MsoNormal" style="MARGIN: 0in 0.9pt 0pt 17.6pt; LINE-HEIGHT: normal; tab-stops: .5in; mso-layout-grid-align: none"><span style="color: #000000;"><span style="FONT-SIZE: 11.5pt; FONT-FAMILY: 'Segoe UI','sans-serif'">We want to write a class that can be used to send an email to a selected email address. This class should have four properties namely: To, From, Subject, and Body, </span><span style="FONT-SIZE: 11.5pt; FONT-FAMILY: 'Segoe UI','sans-serif'; mso-ansi-language: DE" lang="DE">and a method to send the email (in the current version, attachements are not covered).<br /></span></span></p><p class="MsoNormal" style="MARGIN: 0in 0.9pt 0pt 17.6pt; LINE-HEIGHT: normal; tab-stops: .5in; mso-layout-grid-align: none">&nbsp;</p><p class="MsoNormal" style="MARGIN: 0in 0.9pt 0pt 17.6pt; LINE-HEIGHT: normal; tab-stops: .5in; mso-layout-grid-align: none">&nbsp;</p><p class="MsoNormal" style="MARGIN: 0in 0.9pt 0pt 17.6pt; LINE-HEIGHT: normal; tab-stops: .5in; mso-layout-grid-align: none">&nbsp;</p>
2 answers

Send an email in C# without attachment

Here is the code snippet for the implementation:System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();message.To.Add("luckyperson@online.microsoft.com");message.Subject = "This is the Subject line";message.From = new System.Net.Mail.MailAddress("From@online.microsoft.com");message.Body = "This is the message body";System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");smtp.Send(message);

Taggings:

C# Source Code to send email

Taggings: