如何实现电子邮件的自动发送?

2023-12-07 0 235

如何实现电子邮件的自动发送?

<%@import namespace=\”system.web.uit\”%>dim mail as new mailmessage

\’ 建立一个mailmessage对象.mail.to=收件人mail.form=送件人mail.subject=主题mail.bodyformat=格式mail.body=内容smtpmail.send(mail) 具体代码如下:

<%@ Import Namespace=\”System.Web.Util\” %> <html>

<head>

<title>千花飞舞之电子邮件发送</title>

</head>

<body BgColor=\”White\”>

<Form runat=\”server\”><Table Border=1><Tr><Td>收件人:</Td><Td><Input Type=\”Text\” id=\”mailTo\” Size=40 runat=\”server\”/></Td></Tr><Tr><Td>发件人:</Td><Td><Input Type=\”Text\” id=\”mailFrom\” Size=40 runat=\”server\”/></Td></Tr><Tr><Td>主题:</Td><Td><Input Type=\”Text\” id=\”mailSubject\” Size=40 runat=\”server\”/></Td></Tr><Tr><Td>内容:</Td><Td><TextArea id=\”mailbody\” Rows=8 Cols=60 runat=\”server\”></TextArea></Td></Tr></Table><Input Type=\”Button\” Value=\”立即发送\” id=\”Button1\”OnServerClick=\”Button1_Click\” runat=\”server\”/></Form><asp:Label id=\”Label1\” runat=\”server\”/></body></html><script Language=\”VB\” runat=\”server\”>Sub Button1_Click(sender As Object, e As EventArgs) Dim mail As MailMessage = New MailMessagemail.To= mailTo.Valuemail.From= mailFrom.Valuemail.Subject= mailSubject.Valuemail.bodyFormat=mail.format.textmail.body= mailbody.Value

\’ 读取表单的mailto等,分别指定给mail对象的to等属性.

SmtpMail.Send(mail)

\’ 调用smtpmail发送.

Label1.Text = \”恭喜,邮件发送成功!\”End Sub</script>

[1]

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 编程10000问 如何实现电子邮件的自动发送? https://www.u-9.cn/biancheng/bc10000/126553.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务