borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Different between ASP and ASP.net)Next Topic (Uploading Picture with database in ASP) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : how i can send mail with asp .net??
Poster Message
karla
Level: Guest


icon how i can send mail with asp .net??

Somebody knows how i can send mail with asp. net

[Edited by karla on 13-01-2003 at 09:52 PM GMT]

13-01-2003 at 09:51 PM
| Quote Reply
zimcoder
Level: VB Lord


Registered: 27-10-2003
Posts: 225
icon Re: how i can send mail with asp .net??

first make sure you have an smtp server running on your machine

include the namespace for mail by doing the following:
in C#
using System.Web.Mail;

then
create an instance of the mailmessage class as follows:

MailMessage MyEmail  = new MailMessage();
            MyEmail.To = txtTo.Text;
            MyEmail.From     = txtFrom.Text;
            MyEmail.Cc       = txtCc.Text;
            MyEmail.Subject  = "Sample Email";
            MyEmail.Body     = txtName.Text + ", " +           txtComments.Text;
//you can set your mail priority if you want
            MyEmail.Priority = MailPriority.High;
    try
{
    SmtpMail.Send(MyEmail);
    Response.Write("Email has been sent !");
  }
  catch (Exception ex)
{
    Response.Write("Sorry your message was not sent because: " + ex.ToString());
}



VB.Net

Imports System.Web.Mail;

Dim MyEmail as New MailMessage()
       MyEmail.To       = txtTo.Text
       MyEmail.From     = txtFrom.Text
       MyEmail.Cc       = txtCc.Text
       MyEmail.Subject  = "Test Email"
       MyEmail.Body     = txtName.Text & ", " &txtComments.Text
      objEmail.Priority = MailPriority.High
    try
    SmtpMail.Send(MyEMail)
    Response.Write(Your E-mail has been sent !)

  catch ex as Exception
    Response.Write("Sorry your message was not sent because: " + ex.ToString)
  End Try

hope you find this helpful


____________________________
BrainBench ADO.NET and ASP.NET Certified Developer

19-11-2003 at 01:56 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ASP.Net : how i can send mail with asp .net??
Previous Topic (Different between ASP and ASP.net)Next Topic (Uploading Picture with database in ASP) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder