SHOW:
|
|
- or go back to the newest paste.
| 1 | Imports System.Net.Mail | |
| 2 | ||
| 3 | ||
| 4 | Public Class Form1 | |
| 5 | Dim emailaddress As String | |
| 6 | Dim password As String | |
| 7 | Dim port As Integer | |
| 8 | Dim host As String | |
| 9 | Public Property Multiselect As Boolean | |
| 10 | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click | |
| 11 | If max.Text = "" Then | |
| 12 | Timer1.Start() | |
| 13 | Else | |
| 14 | Me.Timer1.Interval = max.Text | |
| 15 | Me.Timer1.Enabled = True | |
| 16 | End If | |
| 17 | If sender.Text.Length = 0 Then Timer1.Stop() | |
| 18 | sent.Text = 0 | |
| 19 | ||
| 20 | ||
| 21 | ||
| 22 | End Sub | |
| 23 | Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click | |
| 24 | Timer1.Stop() | |
| 25 | ||
| 26 | End Sub | |
| 27 | Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick | |
| 28 | ||
| 29 | emailaddress = usernamebox.Text | |
| 30 | password = passwordbox.Text | |
| 31 | If emailaddress.ToLower.Contains("@hotmail") Or emailaddress.ToLower.Contains("@live") Or emailaddress.ToLower.Contains("@msn") Then
| |
| 32 | port = 587 | |
| 33 | host = "Smtp.live.com" | |
| 34 | ElseIf emailaddress.ToLower.Contains("@gmail") Then
| |
| 35 | port = 587 | |
| 36 | host = "smtp.gmail.com" | |
| 37 | ElseIf emailaddress.ToLower.Contains("@aol") Then
| |
| 38 | port = 587 | |
| 39 | host = "smtp.aol.co.uk" | |
| 40 | ElseIf emailaddress.ToLower.Contains("@yahoo") Then
| |
| 41 | port = 465 | |
| 42 | host = "smtp.mail.yahoo.com" | |
| 43 | End If | |
| 44 | Dim MyMailMessage As New MailMessage() | |
| 45 | ||
| 46 | Dim SMTPServer As New SmtpClient | |
| 47 | ||
| 48 | MyMailMessage.From = New MailAddress(emailaddress) | |
| 49 | MyMailMessage.To.Add(tobox.Text) | |
| 50 | ||
| 51 | MyMailMessage.Subject = (subjectbox.Text) | |
| 52 | ||
| 53 | MyMailMessage.Body = messagebox.Text | |
| 54 | ||
| 55 | If Not Browse.Text = Nothing Then | |
| 56 | Dim attach As Net.Mail.Attachment = New Net.Mail.Attachment(Browse.Text) | |
| 57 | MyMailMessage.Attachments.Add(attach) | |
| 58 | End If | |
| 59 | ||
| 60 | SMTPServer.Port = port | |
| 61 | SMTPServer.Host = host | |
| 62 | ||
| 63 | SMTPServer.EnableSsl = True | |
| 64 | ||
| 65 | SMTPServer.Credentials = New System.Net.NetworkCredential(emailaddress, password) | |
| 66 | ||
| 67 | ||
| 68 | Try | |
| 69 | sent.Text = Val(sent.Text + 1) | |
| 70 | SMTPServer.Send(MyMailMessage) | |
| 71 | If sent.Text = max.Text Then Timer1.Stop() | |
| 72 | Catch exc As Net.Mail.SmtpException | |
| 73 | Timer1.Stop() | |
| 74 | sent.Text = 0 | |
| 75 | MsgBox("Check Your password, Your Email and To Email! Read 'Help and Info' for Details")
| |
| 76 | ||
| 77 | End Try | |
| 78 | If email.Checked = True Then | |
| 79 | My.Settings.username = usernamebox.Text | |
| 80 | My.Settings.Save() | |
| 81 | My.Settings.Reload() | |
| 82 | End If | |
| 83 | If pass.Checked = True Then | |
| 84 | My.Settings.password = passwordbox.Text | |
| 85 | My.Settings.Save() | |
| 86 | My.Settings.Reload() | |
| 87 | End If | |
| 88 | ||
| 89 | End Sub | |
| 90 | Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click | |
| 91 | Dim file As String | |
| 92 | Me.OpenFileDialog1.Multiselect = True | |
| 93 | Me.OpenFileDialog1.Title = "Browse Attachments..." | |
| 94 | If OpenFileDialog1.ShowDialog = DialogResult.OK Then | |
| 95 | For Each file In OpenFileDialog1.FileNames | |
| 96 | browse.Items.Add(file) | |
| 97 | Next | |
| 98 | End If | |
| 99 | ||
| 100 | ||
| 101 | End Sub | |
| 102 | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load | |
| 103 | usernamebox.Text = My.Settings.username | |
| 104 | passwordbox.Text = My.Settings.password | |
| 105 | ||
| 106 | ||
| 107 | End Sub | |
| 108 | Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click | |
| 109 | My.Settings.password = passwordbox.Text | |
| 110 | My.Settings.Reset() | |
| 111 | My.Settings.Reload() | |
| 112 | My.Settings.username = usernamebox.Text | |
| 113 | My.Settings.Reset() | |
| 114 | My.Settings.Reload() | |
| 115 | usernamebox.Text = Nothing | |
| 116 | passwordbox.Text = Nothing | |
| 117 | End Sub | |
| 118 | Private Sub clearall_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearall.Click | |
| 119 | Dim tbox As Control | |
| 120 | For Each tbox In Me.Controls | |
| 121 | If TypeOf tbox Is TextBox Then | |
| 122 | tbox.Text = Nothing | |
| 123 | End If | |
| 124 | Next | |
| 125 | sent.Text = 0 | |
| 126 | End Sub | |
| 127 | Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click | |
| 128 | Form3.Show() | |
| 129 | End Sub | |
| 130 | Private Sub passwordbox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles _ | |
| 131 | passwordbox.Validating ' enz.... | |
| 132 | ||
| 133 | If sender.Text.Length = 0 Then | |
| 134 | ||
| 135 | e.Cancel = False | |
| 136 | sender.Select(0, sender.Text.Length) | |
| 137 | ErrorProvider1.SetError(sender, "necessary input!") | |
| 138 | ||
| 139 | Else | |
| 140 | ' everything is ok | |
| 141 | ErrorProvider1.SetError(sender, "") | |
| 142 | ||
| 143 | End If | |
| 144 | ||
| 145 | End Sub | |
| 146 | Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click | |
| 147 | End | |
| 148 | End Sub | |
| 149 | Private Sub usernamebox_Validating(ByVal sender1 As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles _ | |
| 150 | usernamebox.Validating ' enz.... | |
| 151 | ||
| 152 | If InStr(1, sender1.text, "@hotmail") Or InStr(1, sender1.text, "@gmail") Or InStr(1, sender1.text, "@live") Or InStr(1, sender1.text, "@yahoo") Or InStr(1, sender1.text, "@aol") Or InStr(1, sender1.text, "@msn") Then | |
| 153 | ||
| 154 | 'everything is ok | |
| 155 | ErrorProvider1.SetError(sender1, "") | |
| 156 | Else | |
| 157 | e.Cancel = False | |
| 158 | ErrorProvider1.SetError(sender1, "Check This! Read 'Help and info' for more info!") | |
| 159 | End If | |
| 160 | End Sub | |
| 161 | Private Sub tobox_Validating(ByVal sender2 As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles _ | |
| 162 | tobox.Validating ' enz.... | |
| 163 | ||
| 164 | If InStr(1, sender2.text, "@") Then | |
| 165 | ErrorProvider1.SetError(sender2, "") | |
| 166 | Else | |
| 167 | e.Cancel = False | |
| 168 | ErrorProvider1.SetError(sender2, "Check This! Read 'Help and info' for more info!") | |
| 169 | End If | |
| 170 | ||
| 171 | End Sub | |
| 172 | ||
| 173 | Private Sub browse_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browse.SelectedIndexChanged | |
| 174 | While browse.SelectedItems.Count > 0 | |
| 175 | browse.Items.Remove(browse.SelectedItem) | |
| 176 | End While | |
| 177 | End Sub | |
| 178 | - | End Class |
| 178 | + | End Class |