blueyecatz (10-21-2014),maarten551 (10-10-2009),selex2808 (04-27-2012)
People made some, no one explained how to was done
most likley because they copy and pasted there code.
hence they all required gmail accounts.
Anyway
Firstly create a new form with
4 x Textboxes
Named
- EmailBox
- SubjBox
- UserBox
- PassBox
1 x RichTextBox
Named
-MsgBox
1 x Timer
Named
- Timer1
3 Buttons
Named / Lable
- SendBtn / Send
- StopBtn / Stop
- ExitBtn / Exit
-------------------------------------------------------
Now double click the form to bring up the source code, insert this
code line at the verry top
-------------------------------------------------------Code:Imports System.Net.Mail
We will now sort the buttons, Starting with SendBtn
Double click the button and add the following code....
Next we move onto the Stop button...Code:Timer1.Start()
The final button ExitCode:Timer1.Stop()
----------------------------------------------------------Code:End
Now lets move onto the timer
Instert the following code after double clicking the timer.
===============================================Code:Dim MyMailMessage As New MailMessage() MyMailMessage.From = New MailAddress(UserBox.Text) MyMailMessage.To.Add(EmailBox.Text) MyMailMessage.Subject = (SubjBox.Text) MyMailMessage.Body = MsgBox.Text Dim SMTPServer As New SmtpClient("smtp.live.com") SMTPServer.Port = 587 SMTPServer.Credentials = New System.Net.NetworkCredential(UserBox.Text, PassBox.Text) SMTPServer.EnableSsl = True SMTPServer.Send(MyMailMessage)
Done, and now to explain that final code block
=============================================Dim MyMailMessage As New MailMessage()
//Gives MyMailMessage the meaning of New MailMessage()
MyMailMessage.From = New MailAddress(UserBox.Text)
//Sets the from email address of our new email to a New MailAddress, based on the content of UserBox.Text
MyMailMessage.To.Add(EmailBox.Text)
// This adds another email address to the send like, based again on the text in the email box
MyMailMessage.Subject = (SubjBox.Text)
// Sets the email subject to the value of SubjBox
MyMailMessage.Body = MsgBox.Text
// Sets the body of the email from what was entered into our rich textbox
"MsgBox"
Dim SMTPServer As New SmtpClient("smtp.live.com")
// Set SMTPServer as a new smtpclient, which is smtp.live.com ( this is the mail server for msn)
SMTPServer.Port = 587
// Set our servers port
SMTPServer.Credentials = New System.Net.NetworkCredential(UserBox.Text, PassBox.Text)
//Get the user information required to send an email from the server
SMTPServer.EnableSsl = True
//EnableSsl ¬_¬
SMTPServer.Send(MyMailMessage)
// And Finally send out email
Now im sorry for any spelling mistakes but i wrote this on the spot
in about 5mins.
Last edited by Gilcrow; 10-10-2009 at 03:16 PM.
blueyecatz (10-21-2014),maarten551 (10-10-2009),selex2808 (04-27-2012)
i found a error :P
need to beCode:Import System.Net.Mail
for the rest:Code:Imports System.Net.Mail
i love the code tnx :P
it works by me
corrected, and uploaded source
Nice tutorial,
im sure this will help some people.
Thanks for posting.