Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Goof Afternoon,

I'm new to coding and need some assistance, I'm going to make this as easy as I can to understand.

Basically I want to be able to input data into a page and write that to an accessdb which I've managed to do using a submit button, but I am also wanting to email that particular record using that submit button for the user who is specified in a dropdownlist.

Button : Button1
DropdownList: DDAssignTo

Outlook

Any more information please let me know

Thanks in advance
Emma
Posted
Updated 15-May-15 11:05am
v2
Comments
ZurdoDev 15-May-15 11:03am    
There are lots of examples online of how to send emails using C# or VB. Where are you stuck?
Emm4 15-May-15 11:10am    
Hi RyanDev In creating the coding behind that submit button, I've taken a look online but because I'm not ofay with coding its just looks like one big mess to me .....

Sending an email is different in both frameworks (.NET framework and ASP.NET framework), although the code of .NET framework would on ASP.NET too, but ASP.NET has a personal implementation of email sending frameworks and objects.

You simply need basic understanding of the SMTP protocol, how SMTP servers work and what is required by your SMTP server to send the emails (different providers have different standards and requirements for allowing the users to use their environment and resources to send emails).

I have a Gmail account that I use regularly, and for development purposes so in the following articles of mine, I have provided code that fits Gmail (and my conditions). You can use other providers also, I have used and tried others also and they work.

Sending Emails Easily Using ASP.NET Helpers[^]
Sending emails over .NET framework, and general problems – using C# code[^]

Convert the code from C# to VB.NET using Telerik Converter.[^].
 
Share this answer
 
v2
ASP.Net uses System.Net.Mail namespace to send mail using smtp mail server so First of all you need to import System.Net.Mail namespace.

Then put below code to your project.

C#
try
            {
                MailMessage mailMessage = new MailMessage();  
                //MailMessage used to Represent Email Message             
                
                mailMessage.To.Add("receiver1@gmail.com");    
                mailMessage.CC.Add("receiver2@gmail.com");
                mailMessage.Bcc.Add("receiver3@gmail.com");
                //Specify receiver email-ID in CC or Bcc                   

                mailMessage.Subject = "This is Mail Subject";
                //Specify Subject of Mail Message

                mailMessage.Body = "This is Mail Body";
                //Specify Body of Mail Message

                //Specify Credential like sender email-id and password   
                System.Net.NetworkCredential credential = new System.Net.NetworkCredential();
                credential.UserName = "sender@gmail.com";
                credential.Password = "Password";

                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                //SmtpClient allow application to send mail using smtp
                //You need to specify host and post Please refer below link to find most frequently used SMTP like google, Yahoo, outlook                   

                smtpClient.Credentials = credential;
                //Specify Credential to SmtpClient object so using this credential Application can send Mail
  
                smtpClient.EnableSsl = true;
                //You can enable SSL to encrypt connection

                smtpClient.Send(mailMessage);
                //Send Message that represent in MailMessage object 
            }
            catch (Exception ex)
            {
                Response.Write("Could not send the e-mail - error: " + ex.Message);
            }


Sending Mail is time consuming task So I suggest you to use Async and Await to send mail.

Most frequently used Port and Host for SMTP like google, Yahoo, outlook
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900