QuestionHelpHelp With Coding

Posts 1–9 of 9 · Page 1 of 1
Help With Coding
Hello. I Need Help With Coding , So Lets Say We Have A Form In Which The Following Items Are There
First Name Label And TextBox
Last Name Label And TextBox
"Send To Applied Email" Button
------------------------------------
Email Label And TextBox
"apply this Email" button
------------------------------------

So Basicly The Person First Inserts His desired Email and clicks the apply button so it basicly well gets saved as settings2.bmr then when the person enters his first name and last name and presses the "send to applied email" button it will basicly send the information of textbox1 and textbox2 to the email he applied.

My code so far you can say is good , i was able to successfully able to do the coding for saving the text so that when the users enters text and clicks the save button lets just say, it'll be saved in example.bmr so next time user opens the program the text he entered before will be there but however i failed to code on sending texts of two textbox's to a specific email which the user has typed in another textbox and clicked on applied . . . !

Thank You
I'm confused. So you have two email boxes or.. Best make a video so I can see what's going on.
Quote Originally Posted by Cryptonic View Post
I'm confused. So you have two email boxes or.. Best make a video so I can see what's going on.
Heres a picture . . .


1.the user enters his email first . . . and clicks on the apply button

2.the email is now saved , to tell you how and a little better , heres the code when the user will click the apply email button and when the next time the form loads.

Code:
Private Sub btn_apply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_apply.Click
        Dim fs As New FileStream("settings2.bmr", FileMode.Create, FileAccess.Write)
        Dim s As New StreamWriter(fs)
        s.BaseStream.Seek(0, SeekOrigin.End)
        s.WriteLine(textbox_email.Text)
        s.Close()
    End Sub
( when the user clicks on apply email button )

Code:
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error Resume Next
        If File.Exists("setting2.bmr") = False Then
            Exit Sub
        End If
        Dim fs = New FileStream("settings2.bmr", FileMode.Open, FileAccess.Read)
        Dim d As New StreamReader(fs)
        d.BaseStream.Seek(0, SeekOrigin.Begin)
        While d.Peek() > -1
            textbox_email.Text &= d.ReadLine()

        End While
        d.Close()
    End Sub
(the next time the form loads)

3.the user then inserts his first name and last name and then clicks on "send to applied email" button.

4.thats pretty much it . . . .

Thanks !

if you still didn't understand i will put a video i guess . . . .
Try to do what Biesi said, I'm still a bit confused. Though you should take out 'On Error Resume Next' and post the error that comes up.

Also upload to imgur or cubeupload, not as an attactment :P
Can you please tell me what your confused about so i can easy it up for you . . . look its simple

please check the screenshot attachment*

1.the user enters any random email he can open in the textbox down then
2.then he enters the first name and last name in two textboxes then clicks on send
3.the first name and last name that he entered would be sent to the email he typed in the textbox down

thats all .. . please tell what your confused about . . i really need the answer

---------- Post added at 08:48 PM ---------- Previous post was at 08:45 PM ----------

Quote Originally Posted by Biesi View Post
1. Simple Mail Transfer Protocol - Wikipedia, the free encyclopedia
2. ^
3. the SMTP server needs your login credentials so you can access and send emails
4. you need the correct server (example: "smtp.mail.yahoo.com"); use 'select case' for different servers
5. 2nd and 3rd go to the button click event
Hello thank you for the answer and the explanation !!!

---------- Post added at 08:54 PM ---------- Previous post was at 08:48 PM ----------

Quote Originally Posted by Biesi View Post
1. Simple Mail Transfer Protocol - Wikipedia, the free encyclopedia
2. ^
3. the SMTP server needs your login credentials so you can access and send emails
4. you need the correct server (example: "smtp.mail.yahoo.com"); use 'select case' for different servers
5. 2nd and 3rd go to the button click event
Hello thank you for the answer and the explanation !!!
He can't see the screen shot becuase it's not approved. Upload it to Imgur or CubeUpload.
Can't you just save the email address in a string?

Code:
Imports System.Net
Imports System.Net.Mail
Code:
Dim smpts As New SmtpClient()
smtps.Host = "???" 'google for the SMTP server you need
smtps.Credentials = New NetworkCredential("username", "password")
Code:
Dim mailmsg As New MailMessage
mailmsg.From = New MailAddress("mail")
mailmsg.To.Add("mail")
mailmsg.Subject = "subject"
mailmsg.Body = "content"
smtps.Send(mailmsg)
Quote Originally Posted by Biesi View Post
Can't you just save the email address in a string?

Code:
Imports System.Net
Imports System.Net.Mail
Code:
Dim smpts As New SmtpClient()
smtps.Host = "???" 'google for the SMTP server you need
smtps.Credentials = New NetworkCredential("username", "password")
Code:
Dim mailmsg As New MailMessage
mailmsg.From = New MailAddress("mail")
mailmsg.To.Add("mail")
mailmsg.Subject = "subject"
mailmsg.Body = "content"
smtps.Send(mailmsg)
Hello , i did not really understand the second code . . .
i am actually a beginner , still learning visual basic programming . . .

Questions :
1 . what is basicly an smtp stands for and what does it do ?
2 . i did not really catch you there on the host part . . . is this necessary , maybe answering the first question might also solve second question .
3 . the 3rd line of the Second code . . . it basicly will send the entered information by the user when he clicks on the send button right ?
4 . Im assuming the the smtp host = "???" . . . might be the port like for gmail ? is it possible to extend the number of ports here since it might be possible user enters maybe a yahoo email or any other , sorry im a beginner so i didn't really know about smtp lolz so im assuming , please correct me if im wrong . .
5 . i dont really get how to sort the code out ? (i should add the codes where?)

What I Think The Code Might Be For Me :
Code:
Dim smpts As New SmtpClient()
smtps.Host = "???" 'google for the SMTP server you need ( did not really understand this )
smtps.Credentials = New NetworkCredential(textbox1.text, textbox2.text)
Code:
Dim mailmsg As New MailMessage
mailmsg.From = New MailAddress("Test@example.com") 'im guessing that adding the email here is not really important right ?
mailmsg.To.Add(textbox_email.text)
mailmsg.Subject = "example"
mailmsg.Body = "example"
smtps.Send(mailmsg)
what i assume this code will do :
it will send the text in maybe for example textbox1 and the text from textbox2 for example to a specific email on another textbox . . . and then ofcourse with few small details . . .

and i basicly hate saving data content in/as strings , it just causes so many problems for me when i start coding for other stuff . . . its like having a junk all over your desktop with the same name and trying to look for what you want . . . thats why i used the filestream option instead . . .

Please correct me if im wrong , im a beginner as i mentioned
Thanks
1. Simple Mail Transfer Protocol - Wikipedia, the free encyclopedia
2. ^
3. the SMTP server needs your login credentials so you can access and send emails
4. you need the correct server (example: "smtp.mail.yahoo.com"); use 'select case' for different servers
5. 2nd and 3rd go to the button click event
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us