Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Email attachment


Email attachment

Author
Message
eita_zuliana
eita_zuliana
Forum God
Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)

Group: Forum Members
Posts: 2, Visits: 15

Imports System

Imports System.Data

Imports System.Net.Mail

Public Class Form8

Implements IDisposable

Dim an As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

If From.Text = "" Or TxtTo.Text = "" Or BodyText.Text = "" Or Subject.Text = "" Then

MsgBox("Please Fill All Fields")

End If

Dim MyMailMessage As New MailMessage()

MyMailMessage.From = New MailAddress("tmlife@stardocs.net")

MyMailMessage.To.Add(TxtTo.Text)

MyMailMessage.Subject = "From: " + From.Text + "To: " + TxtTo.Text + "Subject:" + Subject.Text

MyMailMessage.Body = BodyText.Text

MyMailMessage.CC.Add("")

MyMailMessage.Bcc.Add("")

MyMailMessage.Subject = ""

'Create the SMTPClient object and specify the SMTP Mail server

Dim SMTPServer As SmtpClient = New SmtpClient

SMTPServer.Port = 587

SMTPServer.Credentials = New System.Net.NetworkCredential("tmlife", "TmLife123")

SMTPServer.EnableSsl = True

If TxtTo.Text = "" Then

Else

Dim oAttch As Attachment = New Attachment(Attachment.Text)

MyMailMessage.Attachments.Add(oAttch)

End If

Try

SMTPServer.Send(MyMailMessage)

MsgBox("Sent")

Catch ex As SmtpException

MessageBox.Show(ex.Message)

End Try

End Sub

Private Sub Attachments_LinkClicked_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles Attachments.LinkClicked

OpenFileDialog1.ShowDialog()

End Sub

Private Sub FolderBrowserDialog1_HelpRequest(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FolderBrowserDialog1.HelpRequest

Attachment.Text = OpenFileDialog1.InitialDirectory

End Sub

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

Attachment.Text = OpenFileDialog1.InitialDirectory

End Sub

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

From.Text = ""

TxtTo.Text = ""

CC.Text = ""

BCC.Text = ""

Attachment.Text = ""

BodyText.Text = ""

Subject.Text = ""

End Sub

Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

End Class


Admin
Admin
Administrator
Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)Administrator (16K reputation)

Group: Administrators
Posts: 81, Visits: 1.3K
Is this a working code snippet or is there a question?


Best regards,

Forum Administrator
A1VBCode



eita_zuliana
eita_zuliana
Forum God
Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)Forum God (604 reputation)

Group: Forum Members
Posts: 2, Visits: 15
I need a help on this code. Sending failure. Can you help me on this . Tq
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search