📄 email.asmx.vb
字号:
Imports System.Web.Services
Imports System.Web.Mail
<WebService(Namespace:="http://localhost/Chapter16")> _
Public Class EMail
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
<WebMethod(Description:="This method sends free " & _
"e-mail")> Public Function SendMail(ByVal strFromAddr As String, ByVal strToAddr As String, ByVal strSubj As String, ByVal strMsg As String) As String
'Free E-Mail Web Service
Dim objCheck As New com.cdyne.ws.ev()
Dim objFromAddr As com.cdyne.ws.ReturnIndicator = objCheck.VerifyEmail(strFromAddr)
Dim objToAddr As com.cdyne.ws.ReturnIndicator = objCheck.VerifyEmail(strToAddr)
Dim intFromCode As Int16 = objFromAddr.ResponseCode
Dim intToCode As Int16 = objToAddr.ResponseCode
If intFromCode = 2 Or intFromCode = 3 Then
If intToCode = 2 Or intToCode = 3 Then
Dim objMail As New MailMessage()
objMail.From = strFromAddr
objMail.To = strToAddr
'Syntax for cc
'objMail.Cc = More Address
'Syntax for Bcc
'objMail.Bcc = More Address
objMail.Subject = strSubj
objMail.Body = strMsg
SmtpMail.SmtpServer = "smtp.comcast.net"
SmtpMail.Send(objMail)
objMail = Nothing
Return "Mail Sent!"
Else
Return "Problem with To Address: " & objToAddr.ResponseText
End If
Else
Return "Problem with From Address: " & objFromAddr.ResponseText
End If
objCheck = Nothing
objFromAddr = Nothing
objToAddr = Nothing
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -