Send Email by SmtpMail : Smtp Email « Socket Network « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Socket Network » Smtp Email 
22.23.1.Send Email by SmtpMail
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 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
22.23.Smtp Email
22.23.1.Send Email by SmtpMail
22.23.2.Socket based SMTP clientSocket based SMTP client
22.23.3.SMTP based on TcpClientSMTP based on TcpClient
22.23.4.Pop3 Email ClientPop3 Email Client
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.