Sending An Email From a Visual Basic Program

How Do I send an Email From a Visual Basic Program?

Page 1 of 1

12 Replies - 2827 Views - Last Post: 15 April 2008 - 03:51 PM Rate Topic: -----

#1 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:23 PM

:blink: I would like to know if there is any easy way to make one of my visual basic 2008 programs send an e-mail

This post has been edited by PsychoCoder: 15 April 2008 - 01:31 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Sending An Email From a Visual Basic Program

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:30 PM

Sending email from a .Net application couldnt be easier. Read up on the System.Net.Mail Namespace, that contains everything you need for accomplishing this.

This post has been edited by PsychoCoder: 15 April 2008 - 01:34 PM

Was This Post Helpful? 0
  • +
  • -

#3 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:33 PM

Thanks Psych I just got thrown off by some topics i found on google all in earlier vb

o also sry i keep 4getting and posting in visual basic rather than .net

View PostPsychoCoder, on 15 Apr, 2008 - 01:30 PM, said:

Sending email from a .Net application couldnt be easier. Read up on the System.Net.Mail Namespace, that contains everything you need for accomplishing this. Also, Visual Basic 2008 is of the .Net variety, so Im moving this to the VB.NET forum :)

Sending email from a .Net application couldnt be easier. Read up on the System.Net.Mail Namespace, that contains everything you need for accomplishing this.

This post has been edited by citricube: 15 April 2008 - 01:34 PM

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:35 PM

No problem, sending email really was simplified with the conversion to VB.Net. You can pretty much send a basic email with about 5 lines of code now
Was This Post Helpful? 0
  • +
  • -

#5 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:37 PM

OoO I guess i need to make a smtp email account now o well
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:38 PM

Why do you need to do this? You're sending it via SMTP, this has nothing to do with what email you say it's from
Was This Post Helpful? 0
  • +
  • -

#7 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:40 PM

O Wow I Don't Understand Very Much But thats good to know

View PostPsychoCoder, on 15 Apr, 2008 - 01:38 PM, said:

Why do you need to do this? You're sending it via SMTP, this has nothing to do with what email you say it's from

Was This Post Helpful? 0
  • +
  • -

#8 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 01:51 PM

:^: Ight those links are helping i think i'm getting the basis
Was This Post Helpful? 0
  • +
  • -

#9 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 02:04 PM

Hmm kinda confused setting the from and to of the email and all

Imports System.Net.Mail

Public Class Form1
	Implements IDisposable
	Dim Mailer As MailMessage
	Dim value As MailAddress
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		Mailer.Body = "Test Body"
		value = Mailer.From
		Mailer.From = value


	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#10 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 02:10 PM

The from and to property of the MailMessage require a MailAddress. Look at the modifications I made to your code example

Imports System.Net.Mail

Public Class Form1
    Implements IDisposable

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Mailer As New MailMessage()
        Dim client As New SmtpClient("127.0.0.1")
        Mailer.To.Add(New MailAddress("youremail@yourdomain.com"))
        Mailer.From = New MailAddress("yourrecipient@theirdomain.com")
        Mailer.Body = "Test Body"

       client.Send(Mailer)
    End Sub
End Class



Now, you would need to replace the 127.0.0.1 I have when I create a new SmtpClient object with the address of your mail server.

This post has been edited by PsychoCoder: 15 April 2008 - 02:10 PM

Was This Post Helpful? 0
  • +
  • -

#11 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 02:24 PM

OoO i don't think i have a mail server

View PostPsychoCoder, on 15 Apr, 2008 - 02:10 PM, said:

The from and to property of the MailMessage require a MailAddress. Look at the modifications I made to your code example

Imports System.Net.Mail

Public Class Form1
    Implements IDisposable

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Mailer As New MailMessage()
        Dim client As New SmtpClient("127.0.0.1")
        Mailer.To.Add(New MailAddress("youremail@yourdomain.com"))
        Mailer.From = New MailAddress("yourrecipient@theirdomain.com")
        Mailer.Body = "Test Body"

       client.Send(Mailer)
    End Sub
End Class



Now, you would need to replace the 127.0.0.1 I have when I create a new SmtpClient object with the address of your mail server.

Was This Post Helpful? 0
  • +
  • -

#12 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 03:23 PM

:blink: Stuck Again Failed Sending Message I used my regular Ip
Was This Post Helpful? 0
  • +
  • -

#13 citricube  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 73
  • Joined: 21-January 08

Re: Sending An Email From a Visual Basic Program

Posted 15 April 2008 - 03:51 PM

:ph34r: nvm figured out how to do one with my gmail account wid credentials and the gmail smtp
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1