System.Web.Mail FAQ

Complete FAQ Listing


2.1 How do I send a simple email? Printer Friendly   Email This FAQ   Discuss

The following example demonstrates SENDING a simple text email.
 
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "localhost";  //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

 

Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
New Post
  • Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
      • RE RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
      • RE RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
    • RE: Massive Email Sending Fails    [ Reply ]
  • What is a real server    [ Reply ]
  • Error in the code    [ Reply ]
  • System.Runtime.InteropServices.COMException: Error de transporte en la conexión al servidor.    [ Reply ]
  • CDO.Message    [ Reply ]
    • RE: CDO.Message    [ Reply ]
    • RE: CDO.Message    [ Reply ]
  • Check the mail has been sent    [ Reply ]
  • Check the mail has been sent    [ Reply ]
  • sending email    [ Reply ]
    • RE: sending email    [ Reply ]
    • RE: sending email    [ Reply ]
    • RE: sending email    [ Reply ]
    • RE: sending email    [ Reply ]
  • Disappering emails?    [ Reply ]
    • RE: Disappering emails?    [ Reply ]
      • RE RE: Disappering emails?    [ Reply ]
  • ..    [ Reply ]
    • RE: ..    [ Reply ]
    • RE: ..    [ Reply ]
    • RE: ..    [ Reply ]
  • email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
      • RE RE: email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
      • RE RE: email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
    • RE: email send fails    [ Reply ]
  • Using System.Web.Mail    [ Reply ]
  • use smtp to send message for yahoo    [ Reply ]
    • RE: use smtp to send message for yahoo    [ Reply ]
  • Sending simple e-mails    [ Reply ]
    • RE: Sending simple e-mails    [ Reply ]
      • RE RE: Sending simple e-mails    [ Reply ]
        • RE: RE RE: Sending simple e-mails    [ Reply ]
    • RE: Sending simple e-mails    [ Reply ]
    • RE: Sending simple e-mails    [ Reply ]
  • Infinite Loop    [ Reply ]
  • can only send mails to intranet but not to internet    [ Reply ]
  • How to send a mail to Yahoo    [ Reply ]
    • RE: How to send a mail to Yahoo    [ Reply ]
  • open smtp server    [ Reply ]
  • email in c#    [ Reply ]
  • Allow dot in email address    [ Reply ]
  • sending email with aol smpt server    [ Reply ]
  • Web.mail    [ Reply ]
  • Web.mail    [ Reply ]
  • cdo.message    [ Reply ]
  • about email error    [ Reply ]
  • error    [ Reply ]
  • About SmtpServer    [ Reply ]
    • RE: About SmtpServer    [ Reply ]
  • System.Net.Mail    [ Reply ]
  • iam not reciving the mail    [ Reply ]
  • How do I include form data in mail.body?    [ Reply ]
  • Checking email sent by feedback    [ Reply ]
  • System.Web.Mail in JScript    [ Reply ]
  • Error in sending mail for the second time    [ Reply ]
  • Error in sending mail for the second time    [ Reply ]
    • RE: Error in sending mail for the second time    [ Reply ]
    • RE: Error in sending mail for the second time    [ Reply ]
  • Problem sending email to yahoo account    [ Reply ]
  • help..am unable to send email    [ Reply ]
    • RE: help..am unable to send email    [ Reply ]
    • RE: help..am unable to send email    [ Reply ]
  • i need an urgent help please    [ Reply ]
  • Problem with System.Web.Mail from VB.NET 2003    [ Reply ]
    • RE: Problem with System.Web.Mail from VB.NET 2003    [ Reply ]
  • simple email    [ Reply ]
  • Could not create 'CDO.Message' object.".    [ Reply ]
  • how to send a simple mail to the external mailing address    [ Reply ]
    • RE: how to send a simple mail to the external mailing address    [ Reply ]
      • RE RE: how to send a simple mail to the external mailing address    [ Reply ]
      • RE RE: how to send a simple mail to the external mailing address    [ Reply ]
      • RE RE: how to send a simple mail to the external mailing address    [ Reply ]
    • RE: how to send a simple mail to the external mailing address    [ Reply ]
  • Email not send    [ Reply ]
  • Fail email form and went to intpub badmail    [ Reply ]
  • Fail email form and went to intpub badmail    [ Reply ]
  • SendingEmail    [ Reply ]
    • RE: SendingEmail    [ Reply ]
    • RE: SendingEmail    [ Reply ]
  • unable to send mail    [ Reply ]
  • help me    [ Reply ]
    • RE: help me    [ Reply ]
      • RE RE: help me    [ Reply ]
        • RE: RE RE: help me    [ Reply ]
        • RE: RE RE: help me    [ Reply ]
          • RE RE: RE RE: help me    [ Reply ]
        • RE: RE RE: help me    [ Reply ]
  • message box wont let me type    [ Reply ]
  • sending email is failed    [ Reply ]
  • 550 Error.    [ Reply ]
    • RE: 550 Error.    [ Reply ]
  • How do i receive the mail?    [ Reply ]
  • Unable to Test Email / ? SmtpServer = "localhost"    [ Reply ]
  • Compilation Error    [ Reply ]
    • RE: Compilation Error    [ Reply ]
    • RE: Compilation Error    [ Reply ]
  • MyMails r getting stacked in te queue folder    [ Reply ]
    • RE: MyMails r getting stacked in te queue folder    [ Reply ]
  • How to get domain server system Ip Address    [ Reply ]
  • sending asp.net email errors    [ Reply ]
  • Need help reading email    [ Reply ]
    • RE: Need help reading email    [ Reply ]
  • Error!!!was not found in the configuration source    [ Reply ]
  • Error in sending email.    [ Reply ]
  • having problem in sending mail    [ Reply ]
    • RE: having problem in sending mail    [ Reply ]
    • RE: having problem in sending mail    [ Reply ]
      • RE RE: having problem in sending mail    [ Reply ]
  • sending e-mail'    [ Reply ]
  • e-mailing    [ Reply ]
  • how to write a C code for email?    [ Reply ]
  • Error    [ Reply ]
  • c language    [ Reply ]
  • e?    [ Reply ]
  • e?    [ Reply ]