Results 1 to 6 of 6

Thread: Email Concept in .Net

  1. #1
    Join Date
    Nov 2009
    Posts
    678

    Email Concept in .Net

    Hello, I am learning .net programming language and while learning it, I am not able to get the details about the email concept. That means I am not able to get to know about the email sending in the asp.net. So, if any one knows the code about it, then please provide me that. It will be helpful to me.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Email Concept in .Net

    You can send email in .net with the code below:
    Code:
    try
            {
                SmtpClient obj = new SmtpClient();
                obj.Host = "ServerName"; 
                obj.Send(txtFrom.Text, txtTo.Text,
                 sub.Text, txtComment.Text);
                Response.Write("Message Sent Successfully");
            }
            catch (Exception e)
            {
                Response.Write(" Delivery Failed");
            }

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Email Concept in .Net

    The Code below will send your email with the help of .net which contains the attachment:
    Code:
    using System.Net.Mail;
    MailMessage message = new MailMessage(From, To, Subject, Body);
    SmtpClient client= new SmtpClient("IP");
    Attachment athmt = new Attachment(attachment);
    athmt.Name = "one.jpg";
    message.Attachments.Add(athmt);

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Email Concept in .Net

    It is simple to send email by the use of .net code, if you make use of the Mailmessage in your coding. I have done that. You can simply make use of it for your purpose:

    Code:
    MailMessage mlmsg = new MailMessage();
    
            MailAddress address = new MailAddress(From.Text,Name.Text);
            mlmsg.From = address;
            mlmsg.To.Add(To.Text);       
            mlmsg.Subject = Subject.Text;        
            mlmsg.Body = Comment.Text;        
            try
            {
                SmtpClient object = new SmtpClient();
                object.Host = "myMailServer"; 
                object.Send(mlmsg);
                Response.Write("Delivery successful");
            }
            catch (Exception ex)
            {
                Response.Write("Failure occured");
            }

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Email Concept in .Net

    I have got the code below which can send email message with the cc and bcc option :
    Code:
     MailMessage mailmessage = new MailMessage();
    
            MailAddress mailaddress = new MailAddress(From,Text,Name,Text);
            mailmessage.From = mailaddress;
            mailmessage.To.Add(To.Text);    
            if(CC.Text.Trim().Length != 0)
               mailmessage.CC.Add(CC.Text);        
            if(BCC.Text.Trim().Length != 0)
                mailmessage.Bcc.Add(BCC.Text);         
            mailmessage.Subject = Subject.Text;        
            mailmessage.Body = Comment.Text;        
            try
            {
                SmtpClient smtpMailObj = new SmtpClient();
                smtpMailObj.Host = "myMailServer"; 
                smtpMailObj.Send(mailmessage);
                Response.Write("Success");
            }
            catch (Exception ex)
            {
                Response.Write("Failed");
            }

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Email Concept in .Net

    You need to use the books below for getting this code:
    • Inside C# (Microsoft Programming) by Tom Archer
    • Programmers at Work by Susan M. Lammers
    • ASP.NET Unleashed by Stephen Walther
    • ASP.NET: Tips, Tutorials and Code by Adam Nathan

Similar Threads

  1. Replies: 3
    Last Post: 18-11-2010, 04:50 PM
  2. Windows live mail couldn't send email but can receive email
    By danielyen in forum Windows Software
    Replies: 1
    Last Post: 15-07-2010, 12:17 AM
  3. Concept of UML
    By Jagadamba in forum Software Development
    Replies: 3
    Last Post: 20-11-2009, 09:53 AM
  4. Replies: 4
    Last Post: 07-03-2008, 07:13 AM
  5. Replies: 2
    Last Post: 14-02-2008, 09:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,119,123.17933 seconds with 17 queries