本文介绍了单击按钮时生成电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击保存时在添加新记录(其中包含其他

字段,该人的电子邮件地址)之后,我希望自动向该人发送一封电子邮件

(在该记录的字段中的电子邮件)。我怎么能这样做?
这样做?


非常感谢,这对我来说真的意义重大!!!


-

通过网站管理员网站发布的消息


解决方案



向该人发送






你的网站主机支持什么?

也许,CDO.Message或ASPMail。



您的Web主机支持什么?
也许,CDO.Message或ASPMail。



-

通过网站管理员网站发布消息





以下:



[snip]


试试这个;请注意自动换行。


Response.Write()语句调用该函数;

修改它以满足您的需要。只需通过

调用该函数传递3个参数:电子邮件地址,主题和正文。


cHST的值(主持人)是GoDaddy所要求的。

cFRM的价值。 (From)是您的电子邮件地址。


Suucess /失败报告已被注释为

您可能希望记录结果而不是显示结果。


<%@ Language =" VBScript" %>

<%Option Explicit


Response.Write(" Email ="& Email(" ne ** @ mckirahan。 com"," Test",Test!))


函数电子邮件(sAddr,sSubj,sBody)

电子邮件=错误

On Error Resume Next

''*

''*声明常数

''*

Const cCDO =" http://schemas.microsoft.com/cdo/configuration/"

Const cHST =" relay-hosting.secureserver.net"

Const cFRM =" postmaster @ {your~domain.com}"

''*

''*发送电子邮件

''*

Dim objCFG

设置objCFG = Server.CreateObject(" CDO.Configuration")

objCFG.Fields.Item( cCDO&sendusing)= 2

objCFG.Fields.Item(cCDO&" smtpserver")= cHST

objCFG.Fields.Item(cCDO& ;" smtpserverport")= 25

objCFG.Fields.Update

Di m objCDO

设置objCDO = Server.CreateObject(" CDO.Message")

objCDO.From = cFRM

objCDO.To = sAddr

''objCDO.BCC =""

''objCDO.CC =""

objCDO.Subject = sSubj

objCDO.TextBody = sBody

''objCDO.HTMLBody = sBody

''objCDO.AddAttachment =""

objCDO.Configuration = objCFG

objCDO.Send

''如果Err = 0那么

''Response.Write(" < br>< br>< b>电子邮件已发送。< / b>")

''否则

''回复。写(< br>< b> Sub Email()< / b>")

''Response.Write("< br>< b> CDO失败:其中/ b" &安培; Err.Description)

''Response.Write(" br>< b> CDO''Addr'':< / b"& sAddr)

''Response.Write("< br>< b> CDO''Subj'':< / b"& sSubj)

''Response.Write(" < br>< b> CDO''Body'':< / b"& sBody)

''结束如果

设置objCDO = Nothing

设置objCFG = Nothing

''*

''*返回

''*

On Error GoTo 0

Email = True

结束功能

%>


When I click "save" after adding a new record (which contains, among other
fields, the person''s email address), I want an email to automatically be sent
to that person (at the email that is in the field of that record). How can I
do this?

Thanks so much, it really means so much to me!!!

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forums.aspx/asp/200710/1

解决方案

sent

I

What does your Web host support?
Perhaps, CDO.Message or ASPMail.



What does your Web host support?
Perhaps, CDO.Message or ASPMail.

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forums.aspx/asp/200710/1


following:

[snip]

Try this; watch for word-wrap.

The Response.Write() statement invokes the function;
modify it to suit your needs. Just call the function by
passing in 3 parms: email address, subject, and body.

The value of "cHST" (Host) is what GoDaddy requires.
The value of "cFRM" (From) is your email address.

Suucess/failure reporting has been commented out as
you may want to log the results rather than display them.

<%@ Language="VBScript" %>
<% Option Explicit

Response.Write("Email = " & Email("ne**@mckirahan.com","Test","Test!"))

Function Email(sAddr,sSubj,sBody)
Email = False
On Error Resume Next
''*
''* Declare Constants
''*
Const cCDO = "http://schemas.microsoft.com/cdo/configuration/"
Const cHST = "relay-hosting.secureserver.net"
Const cFRM = "postmaster@{your~domain.com}"
''*
''* Send Email
''*
Dim objCFG
Set objCFG = Server.CreateObject("CDO.Configuration")
objCFG.Fields.Item(cCDO & "sendusing") = 2
objCFG.Fields.Item(cCDO & "smtpserver") = cHST
objCFG.Fields.Item(cCDO & "smtpserverport") = 25
objCFG.Fields.Update
Dim objCDO
Set objCDO = Server.CreateObject("CDO.Message")
objCDO.From = cFRM
objCDO.To = sAddr
''objCDO.BCC = ""
''objCDO.CC = ""
objCDO.Subject = sSubj
objCDO.TextBody = sBody
''objCDO.HTMLBody = sBody
''objCDO.AddAttachment = ""
objCDO.Configuration = objCFG
objCDO.Send
'' If Err = 0 Then
'' Response.Write("<br><br><b>E-mail has been sent.</b>")
'' Else
'' Response.Write("<br><b>Sub Email()</b>")
'' Response.Write("<br><b>CDO Failed:</b" & Err.Description)
'' Response.Write("<br><b>CDO ''Addr'':</b" & sAddr)
'' Response.Write("<br><b>CDO ''Subj'':</b" & sSubj)
'' Response.Write("<br><b>CDO ''Body'':</b" & sBody)
'' End If
Set objCDO = Nothing
Set objCFG = Nothing
''*
''* Return
''*
On Error GoTo 0
Email = True
End Function
%>


这篇关于单击按钮时生成电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:46