Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Send Email Via SMTP

combobox send email mailmessage

  • Please log in to reply
4 replies to this topic

#1 VBnet

VBnet

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 08 May 2009 - 10:46 AM

Hello CodeCall, I will be showing you how to send emails with VB

You will need:
2 Buttons
and 1 Textbox (2 optional if you want to make a login, error reporter)


Place 1 first Textbox on the form.

Then after resizing the textbox, add a button, change it to "Send Email" and add:
Code:
Dim smtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        smtpServer.Credentials = New Net.NetworkCredential("[COLOR="Lime"]fertyl5@gmail.com[/COLOR]", "[COLOR="Lime"]fertyl200[/COLOR]")
        'using gmail
        smtpServer.Port = 587
        smtpServer.Host = "smtp.gmail.com"
        smtpServer.EnableSsl = True
        mail = New MailMessage()
        mail.From = New MailAddress("[COLOR="Lime"]fertyl5@gmail.com[/COLOR]")
        mail.To.Add("[COLOR="Red"]admin@gamerschannel.net[/COLOR]")
        mail.Subject = ComboBox1.SelectedItem.ToString
        mail.Body = TextBox1.Text
        smtpServer.Send(mail)
        MsgBox("Mail Sent Succesfull!")

Everything that ive marked with red, those you need to change! if marked with green you dont need, only optional.

Then take this:
Code:
imports system.net.Mail
and put it over "Public Class Form1"

and you are done!

Debug the program and test it out, and remember the mail goes to the mail entered "mail.To.Add("Youremailhere@gmail.com")"

AND BTW! IT HAS TO BE GMAIL AS SMTP

and now you are done!

Dont forget to be nice to me when writing back , Bye Bye!!:)
  • 0

#2 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 17 May 2009 - 01:26 AM

do you call this much better than mine? You don't even check if the addresses exists, and what if the mail wasn't sent "Succesfull!"?
  • 0

#3 Heagu

Heagu

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 22 May 2009 - 06:57 AM

Yeah , thats awesome , tried it with some friends ^^ you can send some cool messages to make them frightened
  • 0

#4 giv3mesmile

giv3mesmile

    CC Newcomer

  • Just Joined
  • PipPip
  • 14 posts

Posted 22 January 2010 - 10:05 AM

Any way i could use this in VB6.0 not .Net version.?
  • 0

#5 nevil119

nevil119

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 27 August 2014 - 01:30 AM

Really descriptive and informative. vba send email


  • 0





Also tagged with one or more of these keywords: combobox, send email, mailmessage