VB.Net by API/System.Web.Mail/MailPriority

Материал из VB Эксперт
Версия от 12:49, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

MailPriority.Normal

   
Imports System.Web.Mail
Imports System.Web.Mail.MailMessage
Imports System.Web.Mail.MailAttachment
Imports System.Web.Mail.SmtpMail
Imports System.IO
Imports System.Text
Imports System.Text.Encoding
Imports System.Threading

Public Class Tester
    Public Shared Sub Main
        Dim mailmsg As System.Web.Mail.MailMessage
        Dim mailAttach As System.Web.Mail.MailAttachment
        Dim i As Integer
    
        Try
          SmtpMail.SmtpServer = "server"
          mailmsg = New MailMessage()
          mailmsg.From = "from@from.net"
          mailmsg.To = "to@to.net"
          mailmsg.Cc = "cc@cc.net"
          mailmsg.Bcc = "bcc@bcc.net"
          mailmsg.Subject = "sub"
    
          mailmsg.BodyEncoding = System.Text.Encoding.UTF8
    
          mailmsg.Body = "body"
    
          mailmsg.BodyFormat = MailFormat.Html
          "mailmsg.BodyFormat = MailFormat.Text
    
          mailAttach = New MailAttachment("c:test.txt")
          mailmsg.Attachments.Add(mailAttach)
    
          mailmsg.Priority = MailPriority.Normal
          mailmsg.Priority = MailPriority.Low
          mailmsg.Priority = MailPriority.High
    
          Dim CurThread As Thread
    
          CurThread = System.Threading.Thread.CurrentThread
    
          SyncLock CurThread
            SmtpMail.Send(mailmsg)
          End SyncLock
    
          mailmsg = Nothing
    
          Console.WriteLine("Send Mail Successfully.")
    
        Catch ex As Exception
          Console.WriteLine("Send Mail Error: " & ex.ToString)
        End Try
    
    End Sub
End Class