VB.Net by API/System.Web.Mail/MailPriority — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:49, 26 мая 2010

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