mail&vb

id_locaas

New member
Joined
Sep 13, 2006
Messages
2
Programming Experience
Beginner
Hello

I have a web application that should send a mail with a text from a textbox to the adress that is in another text box.

Can anyone tell me how 2 do this or send me a link to a tutorial... ? plz

10x
 
Put the following control on your form...

Two labels (one with the text 'From' the with the text 'To')
Two Textboxes below the labels (name them 'TextboxFrom' and 'TextboxTo')

Add another Label witht the text SMPTServer
Add another Textbox name it TextboxSMPTServer

Add another label with the text 'Message'
Add another textbox with the name TextboxMessage (set it's muiltiline propery to true)

Add a button named 'ButtonSend' and change it's text to 'Send'

At the top of the class import the following.

VB.NET:
Imports System.Web.Mail


Then declare the following

VB.NET:
Dim MySMTPMail As System.Web.Mail.SmtpMail
Dim Mailmsg As New System.Web.Mail.MailMessage()

Double click the send button to open up the event handler and put in the following...


VB.NET:
If TextboxSMTPServer.Text.Length<0 then
MessageBox.Show("Please Enter SMPT Server Information")
Exit Sub
'Add all the validation for the other textboxes i.e from,to, message etc...


VB.NET:
MySMTPMail.SMTPServer = TextBoxSMTPServer.Text
 
MailMsg.To = TextBoxTo.Text
 
MailMsg.From = TextBoxFrom.Text
 
MailMsg.BodyFormat = MailFormat.Text
 
MailMessage.Body = TextBoxMessage.Text
 
MySMTPMail.Send(MailMsg)
 
Back
Top