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

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

MailMessage.Attachments.Add

  

Imports System
Imports System.Web
Imports System.Web.Mail
Imports System.Data
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.ruponentModel
Public Class Tester
    Public Shared Sub Main
    
        Dim mails As New MailMessage
        mails.From = "from@from.net"
        mails.To = "to@to.net"
        mails.Subject = "message"
        mails.Cc = "cc@cc.net"
        mails.Body = "this is the message"
        mails.BodyEncoding = System.Text.Encoding.UTF8
        mails.BodyFormat = MailFormat.Html
        mails.Attachments.Add("c:\\test.txt")
        SmtpMail.Send(mails)
        
    End Sub
End Class


MailMessage.Body

  
Imports System.Web.Mail
Module Module1
    Sub Main()
        Dim Smtp As SmtpMail
        Smtp.SmtpServer = "Put Your STMP Server Address Here"
        Dim Msg As MailMessage = New MailMessage()
        Msg.Body = "Demo message from a program"
        Msg.From = "fromEmail@SomeSite.ru"
        Msg.To = "toEMail@SomeSite.ru"
        Msg.Subject = "Demo Message"
        Smtp.Send(Msg)
    End Sub
End Module


MailMessage.From

  
Imports System.Web.Mail
Module Module1
    Sub Main()
        Dim Smtp As SmtpMail
        Smtp.SmtpServer = "Put Your STMP Server Address Here"
        Dim Msg As MailMessage = New MailMessage()
        Msg.Body = "Demo message from a program"
        Msg.From = "fromEmail@SomeSite.ru"
        Msg.To = "toEMail@SomeSite.ru"
        Msg.Subject = "Demo Message"
        Smtp.Send(Msg)
    End Sub
End Module


MailMessage.Subject

  
Imports System.Web.Mail
Module Module1
    Sub Main()
        Dim Smtp As SmtpMail
        Smtp.SmtpServer = "Put Your STMP Server Address Here"
        Dim Msg As MailMessage = New MailMessage()
        Msg.Body = "Demo message from a program"
        Msg.From = "fromEmail@SomeSite.ru"
        Msg.To = "toEMail@SomeSite.ru"
        Msg.Subject = "Demo Message"
        Smtp.Send(Msg)
    End Sub
End Module


MailMessage.To

  
Imports System.Web.Mail
Module Module1
    Sub Main()
        Dim Smtp As SmtpMail
        Smtp.SmtpServer = "Put Your STMP Server Address Here"
        Dim Msg As MailMessage = New MailMessage()
        Msg.Body = "Demo message from a program"
        Msg.From = "fromEmail@SomeSite.ru"
        Msg.To = "toEMail@SomeSite.ru"
        Msg.Subject = "Demo Message"
        Smtp.Send(Msg)
    End Sub
End Module