如何从html页面发送电子邮件 [英] how to send email from html page
本文介绍了如何从html页面发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从html页面发送电子邮件
how to send email from html page
推荐答案
您无法从HTML发送邮件。 HTML是一种标记语言。如果你想用JavaScript发送它,你可以用AJAX请求来做,但是你需要一个服务器端语言,比如ASP.NET或PHP,你不能只使用JavaScript。
要用C#(ASP.NET中使用的一种可能的语言)发送邮件,请看这里:
使用或不使用附件在C#中发送电子邮件:通用例程。 [< a href =http://www.codeproject.com/Tips/163829/Sending-an-Email-in-C-with-or-without-attachmentstarget =_ blanktitle =New Window> ^ ]
用PHP发送邮件:
http://php.net/manual/en/function.mail.php [ ^ ]
这是一个关于AJAX的教程,可用于向服务器发送请求以发送邮件:
https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started [ ^ ]
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[^]
你无法使用HTML发送邮件,
发送电子邮件你必须使用ASP.NET,PHP等脚本语言。:)
使用c#发送邮件 [ ^ ]
使用php发送邮件 [ ^ ]
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[^]
如果您正在使用,请调用此函数VB.NET,可以转换为C#
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
这篇关于如何从html页面发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文