Question Visual Basic e-mail to e-mail (code done 1 problem)

griffithdesign

Active member
Joined
Sep 17, 2008
Messages
34
Programming Experience
Beginner
I am making a program where you can send text messages to people. And as you can see I ran into a problem. I am trying to load everything from text boxes because I want everyone to be able to use it. So dose anyone know how to fix my code?

Ordinal Code:
VB.NET:
mail.From = New MailAddress("youre-mail@yourprovider.com)

Code I have:
VB.NET:
mail.From = New MailAddress(TextBox6.Text)
When I run this it says it dose not work and it says it needs to load properly. I would very much appreciated if you would look and figure out what I can do. Thank you very much.






Other Codes I have tried:
VB.NET:
mail.From = New MailAddress = TextBox6.Text  (Error: Overload)
VB.NET:
mail.From = New MailAddress.TextBox6.Text  (Error: Textbox6 is not defined)
 
First, are you using winforms or webforms?
Second, this has nothing to do with Visual Studio .NET (you can write .NET code without VS.NET) so this post needs to be moved once we find out the answer to the above question.
When I run this it says it dose not work and it says it needs to load properly.
Please provide the whole error message. The code looks OK; what needs to load? Maybe you need to post more code for us to understand what's happening.

And I don't suggest you dose anyone. At least not without their knowledge...
 
Alright here is my source code:
Imports System.Web
Imports System.IO
Imports System.Net.Mail
Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox5.Text = ""
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient
SmtpServer.Credentials = New Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
SmtpServer.Port = 587
ProgressBar1.Value = 10
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
ProgressBar1.Value = 20
SmtpServer.EnableSsl = True
mail.To.Add(TextBox3.Text)
ProgressBar1.Value = 40
mail.From = New MailAddress(TextBox6.Text)
ProgressBar1.Value = 60
mail.Subject = TextBox4.Text
ProgressBar1.Value = 80
mail.Body = TextBox5.Text
ProgressBar1.Value = 100
MsgBox("Message sent!")
ProgressBar1.Value = 0
SmtpServer.Send(mail)
My.Computer.Audio.Play(My.Resources.Sent_Sound_Effect_wav, AudioPlayMode.Background)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class
It will give you 1 error because the sound effect is not included.
 
I'd love to help, but as a general rule I don't respond to posts full of variable names like TextBox6, Button247, Label 191.. Name your controls properly!

This is missing a " at the end:
mail.From = New MailAddress("youre-mail@yourprovider.com)

This would work fine:
mail.From = New MailAddress(TextBox6.Text)
 
Back
Top