Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to send email from html page
Posted

You cannot send a mail from HTML. HTML is a markup language. If you want to send it with JavaScript, you can do that with an AJAX request, but you will need a server-side language there, such as ASP.NET or PHP, you cannot do it with only JavaScript.

To send a mail in C# (a possible language that is used in ASP.NET), have a look here:
Sending an Email in C# with or without attachments: generic routine.[^]
To send a mail in PHP:
http://php.net/manual/en/function.mail.php[^]
And here is a tutorial about AJAX, which can be used to send a request to the server to send the mail:
https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started[^]
 
Share this answer
 
You can not send mail using HTML ,
to send email you have to use scripting language like ASP.NET ,PHP etc.. :)

send mail using c#[^]

send mail using php[^]
 
Share this answer
 
Call this function, if you are using VB.NET, can be converted to C#

Public Function SendEmailMessage(ByVal FromAddress As String, _
                                    ByVal FromName As String, _
                                    ByVal ToAddress As String, _
                                    ByVal strSubject As String, _
                                    ByVal strMessage As String, _
                                    ByVal Attachment As String) As String



       Dim oMAIL As New System.Net.Mail.MailMessage
       Dim oSMTP As New System.Net.Mail.SmtpClient

       SendEmailMessage = ""

       oSMTP.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")


       oSMTP.Host = "SMTP HOST"
       oSMTP.Port = 25

       Try
           oMAIL.From = New System.Net.Mail.MailAddress(FromAddress, FromName, System.Text.Encoding.UTF8)
       Catch ex As Exception
           Return Err.Description
       End Try

       If Len(ToAddress) > 0 Then
           oMAIL.To.Add(ToAddress)
           oMAIL.Subject = strSubject
           oMAIL.Body = strMessage



           Try
               If Len(Attachment) > 0 Then
                   Dim oAttachment As New System.Net.Mail.Attachment(Attachment)
                   oMAIL.Attachments.Add(oAttachment)
               End If

               oMAIL.ReplyTo = New System.Net.Mail.MailAddress(FromAddress)
               oSMTP.Send(oMAIL)
               SendEmailMessage = "Success"
           Catch ex As Exception
               SendEmailMessage = Err.Description
           End Try

       End If

       oSMTP = Nothing
       oMAIL = Nothing

       Return SendEmailMessage

   End Function
 
Share this answer
 
if u want to send emails u have to use asp or vb
 
Share this answer
 

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