发送邮件code在ASP [英] Sending Mail code in ASP

查看:347
本文介绍了发送邮件code在ASP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经给了一个HTML文件。当有人填写表格和放大器;发送它,它应该发送电子邮件到他们的邮件ID。如何写code这在ASP?

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?


  • Gnaniyar祖拜尔

推荐答案

使用CDOSYS是这样的: -

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

当然,你需要得到从您存储的用户配置文件,并从发布的场供给人体的主题和protions一些持久存储现场。

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.

您还需要在IIS应用程序提供一个默认配置CDO.Message对象配置邮件设置。如果做不到这一点,你需要自己使用配置邮件设置这样的功能: -

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

然后调用之前发送这一行添加到code的主体: -

Then add this line to the main body of code before calling send:-

Set oMsg.Configuration = GetConfiguration()

仅仅调整了的GetConfiguration内容使用您的SMTP服务器的主机名。

Just tweak the the GetConfiguration content to use your SMTP servers host name.

请注意不要使用CDONTS其德precated。

Note don't use CDONTS its deprecated.

这篇关于发送邮件code在ASP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆