none
Sending a filled form through email.

    Question

  • I have created a form in a aspx web page. When I submit that form all the information is saved in sql database. Now I want to send that form to another person through email. That if he see or open that , he can see the filled form. Now how Can I do this. I really need a suggestion please reply me as soon as possible.
    Sunday, April 28, 2013 4:18 PM

Answers

  • Step 1:

    Create a new project in Microsoft Visual Studio 2008 (File -> New -> Project -> Visual C# -> Console Application)

    Give an appropriate name (in this case ‘SendEmail’) and also specify the location where to store the project. Leave remaining options untouched.

    This step created a console application, where we can create the classes we want and execute them from the command prompt.

    Step 2:

    Now add a new item to the project we just created (Project -> Add New Item -> Class).

    Specify a name to the class (here it is ‘Email’). The code now looks like as follows.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace SendEmail
    {
        class Email
        {
        }
    }

     

    This completes the basic setup of the project. Now we will see what are the namespaces required to send an email.                                         

                                                                                                                                  

    Step 3:

    Import the below namespaces – (just type them after ‘using System.Text’)

    using System.Net.Mail;
    using System.Net.Mime;

    System.Net.Mail – by importing this namespace we can use the inbuilt classes like SmtpClient, MailMessage, MailAddress in our code, which are the important classes required to send email.

    System.Net.Mime – by importing this we can send email using Multipurpose Internet Mail Extensions like by specifying attachments like pdf’s, sending images in the body of email etc.

    Add the Main thread to the class. So at the end of the section the code should be as follows.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Mail;
    using System.Net.Mime;
    
    namespace SendEmail
    {
        class Email
        {
            public static void Main(string[] args)
            {
            }
        }
    }
    Step 4:

    Now comes the important coding to accomplish email task. For the sake of understanding the process, the complete code is divided into five blocks.

    Block 1:

    Create objects of MailMessage and SmtpClient –

    MailMessage m = new MailMessage();
    SmtpClient sc = new SmtpClient();
    Sunday, April 28, 2013 6:46 PM
  • Hello Faiza,

    Well, there are two ways to solve this.

    1.) The quickest one it to handle the sending of email through SQL server from trigger event. I think this link will help you out.

    2.) Second approach is to create a send mail class and implement SmtpClient. Refer to this class library. But still, you need to have a Smtp server in order to send emails.

    Good luck!


    Eric


    Failure is not the worst thing in the world. The very worst is not to try. Email Address : ericjohnadamos@gmail.com. http://ericjohnadamos.blogspot.com/

    Monday, April 29, 2013 1:47 AM

All replies

  • Hi,

    Usually email contains the key information. But if there is a business requirement to send the entire form, you can enter entire form in HTML format in the email body. Please make sure that you remove the actuon buttons.

    Hope this helps..

    Rajat.


    Rajat. Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Mark As Answer".

    Sunday, April 28, 2013 4:39 PM
  • What about creating a report in the database an html report, and then sending the link to the report.  You could also attached the report to the body of the html body of the email.

    jdweng

    Sunday, April 28, 2013 6:30 PM
  • Step 1:

    Create a new project in Microsoft Visual Studio 2008 (File -> New -> Project -> Visual C# -> Console Application)

    Give an appropriate name (in this case ‘SendEmail’) and also specify the location where to store the project. Leave remaining options untouched.

    This step created a console application, where we can create the classes we want and execute them from the command prompt.

    Step 2:

    Now add a new item to the project we just created (Project -> Add New Item -> Class).

    Specify a name to the class (here it is ‘Email’). The code now looks like as follows.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace SendEmail
    {
        class Email
        {
        }
    }

     

    This completes the basic setup of the project. Now we will see what are the namespaces required to send an email.                                         

                                                                                                                                  

    Step 3:

    Import the below namespaces – (just type them after ‘using System.Text’)

    using System.Net.Mail;
    using System.Net.Mime;

    System.Net.Mail – by importing this namespace we can use the inbuilt classes like SmtpClient, MailMessage, MailAddress in our code, which are the important classes required to send email.

    System.Net.Mime – by importing this we can send email using Multipurpose Internet Mail Extensions like by specifying attachments like pdf’s, sending images in the body of email etc.

    Add the Main thread to the class. So at the end of the section the code should be as follows.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Mail;
    using System.Net.Mime;
    
    namespace SendEmail
    {
        class Email
        {
            public static void Main(string[] args)
            {
            }
        }
    }
    Step 4:

    Now comes the important coding to accomplish email task. For the sake of understanding the process, the complete code is divided into five blocks.

    Block 1:

    Create objects of MailMessage and SmtpClient –

    MailMessage m = new MailMessage();
    SmtpClient sc = new SmtpClient();
    Sunday, April 28, 2013 6:46 PM
  • Hello Faiza,

    Well, there are two ways to solve this.

    1.) The quickest one it to handle the sending of email through SQL server from trigger event. I think this link will help you out.

    2.) Second approach is to create a send mail class and implement SmtpClient. Refer to this class library. But still, you need to have a Smtp server in order to send emails.

    Good luck!


    Eric


    Failure is not the worst thing in the world. The very worst is not to try. Email Address : ericjohnadamos@gmail.com. http://ericjohnadamos.blogspot.com/

    Monday, April 29, 2013 1:47 AM