в

ASP.NET

Всичко за платформата, която познавате и използвате

Код за SMTP Mail

Последни съобщения 12-19-2008 19:13 от ksarafov. 1 отговор (а).
Page 1 of 1 (2 items)
Sort Posts: Предишен Следващ
  • 12-19-2008 11:09

    • vasil
    • Top 10 Contributor
    • Joined on 11-29-2008
    • Posts 3

    Код за SMTP Mail

    Може ли някой да ми помогне с код за изпращане на EMAIL от УЕБ приложение

    Свързано с:
    • 78.83.175.238
  • 12-19-2008 19:13 В отговор на

    Re: Код за SMTP Mail

    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

    Свързано с:
    • 78.83.175.238
Page 1 of 1 (2 items)
Copyright ASPbg.NET, Powered by ASPhostBG
Powered by Community Server (Non-Commercial Edition), by Telligent Systems