Results 1 to 6 of 6
  1. #1
    deathninjak0's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    1,510
    Reputation
    12
    Thanks
    294
    My Mood
    Cool

    [Tutorial] Email Sender - Attachments

    First off the credits go to my friend for most of the code in attachments, codenstuff. And youtube for the email sender.

    SMTP email account is needed to use this application.


    To make the email sender you will need the following on your forms and the code included:


    *Form1 - 4 Textboxes
    *Form1 - 3 Buttons
    *Form1 - 3 Labels
    *Form1 - 1 Checkbox / 1 openfiledialog control
    *Form2 - 4 Textboxes
    *Form2 - 4 Labels / 1 Button

    THE CODE FOR THIS PROGRAM:

    FORM1......

    Code:
    Imports System.Net.Mail
    Public Class Form1
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    'Used to select file for attachment
    OpenFileDialog1.ShowDialog()
    TextBox4.Text = OpenFileDialog1.FileName
    End Sub
    
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
    
    'Gets the user settings for email server
    Button2.Enabled = False
    Dim froma AsString
    Dim Serv AsString
    Dim user AsString
    Dim pword AsString
    froma = Convert.ToString(My.Settings.From)
    Serv = Convert.ToString(My.Settings.server)
    user = Convert.ToString(My.Settings.uname)
    pword = Convert.ToString(My.Settings.pass)
    
    'Sends the email and attachment
    Dim from As New MailAddress(froma)
    Dim [to] As New MailAddress(Me.TextBox1.Text)
    Dim theMailMessage As New MailMessage(from, [to])
    Dim filez = TextBox4.Text
    theMailMessage.Body = Me.TextBox3.Text
    If CheckBox1.Checked Then
    theMailMessage.Attachments.Add(New Attachment(filez))
    End If
    theMailMessage.Subject = TextBox2.Text
    Dim theClient As New SmtpClient(Serv)
    theClient.UseDefaultCredentials = False
    Dim theCredential As New System.Net.NetworkCredential(user, pword)
    theClient.Credentials = theCredential
    theClient.EnableSsl = True
    Try
    theClient.Send(theMailMessage)
    Catch wex As Net.WebException
    MessageBox.Show("Could not send email...check your settings.")
    End Try
    Button2.Enabled = True
    End Sub
    
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    
    'Opens the settings form
    Dim theSecondForm As New Form2()
    theSecondForm.ShowDialog()
    End Sub
    
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    
    'Controls attachment box
    If CheckBox1.Checked Then
    Button1.Enabled = True
    TextBox4.Enabled = True
    Else
    Button1.Enabled = False
    TextBox4.Enabled = False
    End If
    End Sub
    End Class

    CODE FOR FORM2....

    Code:
    Public Class Form2
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    'Saves settings and closes form
    My.Settings.From = TextBox1.Text
    My.Settings.server = TextBox2.Text
    My.Settings.uname = TextBox3.Text
    My.Settings.pass = TextBox4.Text
    My.Settings.Save()
    Me.Close()
    End Sub
    
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    'Loads the settings into the form when it is opened
    Dim froma AsString
    Dim Serv AsString
    Dim user AsString
    Dim pword AsString
    froma = Convert.ToString(My.Settings.From)
    TextBox1.Text = froma
    Serv = Convert.ToString(My.Settings.server)
    TextBox2.Text = Serv
    user = Convert.ToString(My.Settings.uname)
    TextBox3.Text = user
    pword = Convert.ToString(My.Settings.pass)
    TextBox4.Text = pword
    End Sub
    End Class
    Lastly, go to MyProject>Settings> and fill out the information

    https://www.virustotal.com/analisis/9...447-1260246592
    Last edited by deathninjak0; 12-07-2009 at 10:35 PM.

  2. #2
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Good TUT! Ill look over the code later but from what i see thts a strange way of sending an email but dont listen to me XD

  3. #3
    deathninjak0's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    1,510
    Reputation
    12
    Thanks
    294
    My Mood
    Cool
    Thank you

  4. #4
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Oh just realized something, you need a Virus Scan. Get one quick b4 pixie sees!

  5. #5
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed
    Give Credits I saw this on alot of different sites....?

  6. The Following User Says Thank You to CoderNever For This Useful Post:

    XGelite (12-08-2009)

  7. #6
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Quote Originally Posted by Coder Never View Post
    Give Credits I saw this on alot of different sites....?
    Yeah I have also seen this!
    -Rest in peace leechers-

    Your PM box is 100% full.

Similar Threads

  1. NEED HELP CODING EMAIL SENDER!!!
    By EvoSpider in forum Visual Basic Programming
    Replies: 7
    Last Post: 06-09-2011, 04:56 PM
  2. [Release] Nexon Email Sender (WEB - NOT DOWNLOAD)
    By ZenoCoder in forum Combat Arms Hacks & Cheats
    Replies: 29
    Last Post: 05-07-2010, 03:38 PM
  3. Email Sender
    By andrew4699 in forum Combat Arms Help
    Replies: 0
    Last Post: 02-14-2010, 03:04 PM
  4. [RELEASE]Email Sender with savable contacts!
    By Pixie in forum Visual Basic Programming
    Replies: 14
    Last Post: 12-05-2009, 01:53 PM
  5. [HELP]Contact list for email sender
    By Pixie in forum Visual Basic Programming
    Replies: 12
    Last Post: 12-05-2009, 12:56 PM