how to sent files in chicklistbox as attachments as I was when I changed the code of adding files to

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi every one
Iam still beginner

I have designed an app witch consist of a button1 and checklistbox1
the button1 used to add files path to checklistbox1
this code that I use<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small =====================================================================
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using<span style="font-size:x-small ofd
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small OpenFileDialog<span style="font-size:x-small <span style="font-size:x-small
ofd.AddExtension =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small True<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small
ofd.CheckFileExists =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small True<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small
ofd.CheckPathExists =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small True<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small
ofd.Filter =
<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small "All files (*.*)|*.*"<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small <span style="font-size:x-small
ofd.FilterIndex = 1
<span style="font-size:x-small
ofd.InitialDirectory =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small My<span style="font-size:x-small .Computer.FileSystem.SpecialDirectories.Desktop<span style="font-size:x-small <span style="font-size:x-small
ofd.Multiselect =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small True<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small
ofd.RestoreDirectory =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small True<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small
ofd.Title =
<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small "Select the files that you want to add to the attachment(s) list"<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If<span style="font-size:x-small ofd.ShowDialog = Windows.Forms.DialogResult.OK
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Then<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Me<span style="font-size:x-small .CheckedListBox1.Items.Add(ofd.FileName)<span style="font-size:x-small




<span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ===================================================================<span style="color:#0000ff; font-size:x-small


<span style="font-size:x-small <span style="font-size:x-small after that I use send all files in checklistbox by this code
<span style="font-size:x-small <span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <span style="font-size:x-small ===========================================================================
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small message
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New
<span style="font-size:x-small MailMessage<span style="font-size:x-small



<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small mail
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New
<span style="font-size:x-small SmtpClient<span style="font-size:x-small
mail.Port =


<span style="color:#800000; font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small
mail.Host =

<span style="color:#800000; font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small
mail.UseDefaultCredentials =

<span style="color:#0000ff; font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small
mail.Credentials =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
<span style="color:#0000ff; font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small
message.From =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New
<span style="font-size:x-small MailAddress(TextBox1.Text)

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small For<span style="font-size:x-small x
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Integer<span style="font-size:x-small = 0
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small To
<span style="font-size:x-small CheckedListBox1.CheckedItems.Count - 1<span style="font-size:x-small




<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small eAttachName
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small String
<span style="font-size:x-small = CheckedListBox1.CheckedItems(x).ToString<span style="font-size:x-small




<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small attach
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New
<span style="font-size:x-small Net.Mail.Attachment(eAttachName)

<span style="color:#0000ff; font-size:x-small

<span style="font-size:x-small <span style="font-size:x-small
mail.EnableSsl =

<span style="color:#0000ff; font-size:x-small

<span style="font-size:x-small
mail.Send(message)
<span style="font-size:x-small

<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Me<span style="font-size:x-small .Label1.Text =
<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small "Email sent successfully to "<span style="font-size:x-small & TextBox3.Text &
<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small "."
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small ==============================================================================
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small than
I changed the code of adding files to chicklistbox1 to this code
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small ==============================================================================
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small
Using ofd As New OpenFileDialog<br/>
ofd.AddExtension = True<br/>
ofd.CheckFileExists = True<br/>
ofd.CheckPathExists = True<br/>
ofd.Filter = "All files (*.*)|*.*"<br/>
ofd.FilterIndex = 1<br/>
ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop<br/>
ofd.Multiselect = True<br/>
ofd.RestoreDirectory = True<br/>
ofd.Title = "Select the files that you want to add to the attachment(s) list"<br/>
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then<br/>
For Each i As String In ofd.FileNames<br/>
Dim x As New IO.FileInfo(i)<br/>
CheckedListBox1.Items.Add(x.Name)<br/>
Next<br/>
End If<br/>
End Using<br/>
===============================================================================
<span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="font-size:x-small <span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small now
I cant sent files in chicklistbox as attachments as I was when I changed the code of adding files to chicklistbox1 to this code

<span style="color:#800000; font-size:x-small <span style="color:#800000; font-size:x-small <span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small

<span style="color:#0000ff; font-size:x-small True

<span style="color:#0000ff; font-size:x-small Next

message.Attachments.Add(attach)
<span style="font-size:x-small





message.To.Add(TextBox3.Text)
message.Subject = TextBox4.Text
message.Body = TextBox5.Text
<span style="font-size:x-small



<span style="color:#0000ff; font-size:x-small

<span style="color:#0000ff; font-size:x-small False

<span style="color:#800000; font-size:x-small "smtp.live.com"

<span style="color:#800000; font-size:x-small "25"




<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small




<br/>

View the full article
 
Back
Top