在ASP中发送邮件代码 [英] Sending Mail code in ASP
问题描述
您的姓名:*
电子邮件:*
电话号码:
您的留言:*
- Gnaniyar Zubair
使用CDOSYS这样: -
Dim oMsg:Set oMsg = CreateObject CDO.Message)
oMsg.From =Me< me@mymail.myserver.com>
oMsg.To =Bloke< bloke@somewere.com>
oMsg.Subject =Test
oMsg.HTMLBody =< html>< body> Hello World< / body>< / html>
oMsg.Send
当然,您需要从To一些持久性商店,您存储用户个人资料,并从发布的字段提供主体和主体的标签。
您还需要在IIS应用程序上配置邮件设置为CDO.Message对象提供默认配置。如果您需要使用以下功能自行配置邮件设置: -
函数GetConfiguration()
Const cdoSendUsingMethod =http://schemas.microsoft.com/cdo/configuration/sendusing
Const cdoSMTPServer =http://schemas.microsoft.com/cdo/configuration/smtpserver
Const cdoSMTPServerPickupDirectory = http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory
Const cdoSMTPServerPort =http://schemas.microsoft.com/cdo/configuration/smtpserverport
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Dim GetConfiguration:SetGetConfiguration = CreateObject(CDO.Configuration)
使用GetConfiguration.Fields
.Item (cdoSendUsingMethod)= cdoSendUsingPort
.Item(cdoSMTPServer)=mysmtp.myserver.com
.Item(cdoSMTPServerPort)= 25
.Update
结束
结束函数
然后在调用send之前将此行添加到主体代码: -
设置oMsg.Configuration = GetConfiguration()
只是调整使用您的SMTP服务器主机名的GetConfiguration内容。
请注意不要使用不推荐的CDONTS。
I have given one HTML file. When someone fills the form & sends it, it should send email to their mail id. how to write code for this in ASP?
Your Name:* Email:* Phone No: Your Message:*- Gnaniyar Zubair
Use CDOSYS like this:-
Dim oMsg : Set oMsg = CreateObject("CDO.Message")
oMsg.From = "Me <me@mymail.myserver.com>"
oMsg.To = "Bloke <bloke@somewere.com>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>Hello World</body></html>"
oMsg.Send
Of course you need to get the To field from some persistent store where you store the users profile and supply the Subject and protions of the body from the posted fields.
You also need to configure the mail settings on the IIS application to supply a default configuration for the CDO.Message object. Failing that you need to configure the mail settings yourself using a function like this:-
Function GetConfiguration()
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPickupDirectory = "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Dim GetConfiguration : SetGetConfiguration = CreateObject("CDO.Configuration")
With GetConfiguration.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mysmtp.myserver.com"
.Item(cdoSMTPServerPort) = 25
.Update
End With
End Function
Then add this line to the main body of code before calling send:-
Set oMsg.Configuration = GetConfiguration()
Just tweak the the GetConfiguration content to use your SMTP servers host name.
Note don't use CDONTS its deprecated.
这篇关于在ASP中发送邮件代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!