Az polzvam tozi kod
Public Class WebMail
Shared FromEmail As String = "yourmail"
Shared Bcc As String = "yourmail"
Shared FromName As String = " "yourmail Team"
Shared Server As String = "'your real server goes here"
Public Shared LogMassage As String
Public Shared LogMassageDetails As String
Public Class WebMailBGEncoding
Public [To] As String
Public Subject As String
Public Body As String
Public Sub Send()
If [To] = "" Then
LogMassage = "Моля, въведете Вашия e-mail!"
Else
If Subject = "" Then
LogMassage = "Моля, въведете тема!"
Else
' System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
' System.Net.Mail.SmtpClient is the alternate class for this in 2.0
Dim smtpClient As SmtpClient = New SmtpClient()
Dim message As New MailMessage
message.BodyEncoding = Encoding.UTF8
Try
Dim fromAddress As MailAddress = New MailAddress(FromEmail, FromName, Encoding.UTF8)
' You can specify the host name or ipaddress of your server
' Default in IIS will be localhost
smtpClient.Host = Server
'Default port will be 25
smtpClient.Port = 25
'From address will be given as a MailAddress Object
message.From = fromAddress
' To address collection of MailAddress
message.To.Add([To])
message.Subject = Subject
' CC and BCC optional
' MailAddressCollection class is used to send the email to various users
' You can specify Address as new MailAddress("admin1@yoursite.com")
'message.CC.Add("admin1@yoursite.com")
' You can specify Address directly as string
message.Bcc.Add(New MailAddress(Bcc))
'Body can be Html or text format
'Specify true if it is html message
message.IsBodyHtml = True
' Message body content
'message.Body = Body
smtpClient.Send(message)
Catch ex As Exception
LogMassage = "Имаше проблем при изпращането на вашия email. Опитайте отново!"
'Catch ex As Exception
LogMassageDetails = CStr(Now()) + ", " + (("Следната грешка беше открита: " + ex.ToString()))
WriteAddRow(LogMassageDetails)
'check the InnerException
While Not (ex.InnerException Is Nothing)
LogMassageDetails += (("<br/>Вътрешна грешка беше открита: " + ex.InnerException.ToString()))
ex = ex.InnerException
End While
End Try
End If
End If
End Sub
End Class
End Class