Email sending?

trickz

New member
Joined
Oct 11, 2008
Messages
3
Programming Experience
Beginner
Hello i would create a application that can sending emails
if should see so:
textbox1=username
textbox2=password
textbox3=to email
textbox4=smtp server
but i dont know how i have tried many things but doesnt work maybe you can help me !

thanks
 
This is the basics, and is a little out of date. But very simple for VB 2008 express or others. Create a form with 5 texts boxes, label them as follows

SMTP Server
From Line/Domain
Sub Line
Sending too email address
Body/MSG

then have one button probably called "Send", double click that button and insert this code. Update the names of the text boxes are you see fit. There are some lines of code i didn't bother using and ' preceeds them. Good luck!

VB.NET:
Dim server As String
        Dim mailto As String
        Dim mailfrom As String
        Dim subject As String
        Dim msg As String

        server = SMTPserver.text
        mailto = testEmail.Text
        mailfrom = DomainName.Text
        subject = SubLine.Text
        msg = Creative.Text 
        'SmtpMail.SmtpServer = server

        'Try
        'SmtpMail.Send(mailfrom, mailto, subject, msg)
        'Catch ex As Exception
        ' MsgBox("Fail")
        ' End Try
        'the above is original send method

        Dim myMail As New MailMessage()
        myMail.From = DomainName.Text
        myMail.To = testEmail.Text
        myMail.Subject = SubLine.Text
        'myMail.Priority = MailPriority.Low
        myMail.BodyFormat = MailFormat.Html
        myMail.Body = Creative.Text
        'Dim myAttachment As New MailAttachment("c:\attach\attach1.txt", MailEncoding.Base64)
        'myMail.Attachments.Add(myAttachment)

        SmtpMail.SmtpServer = server

        Try
            SmtpMail.Send(myMail)

        Catch ex As Exception
            MsgBox("Fail")
        End Try
 
its doenst work its came many mistakes .... :(

edit:maybe i make a mistake maybe anyone can make an example and upload it that were nice
 
its doenst work its came many mistakes .... :(

edit:maybe i make a mistake maybe anyone can make an example and upload it that were nice


Sorry i did forget that one important line. At the very top of your source code type these three imports, just to be safe.

Imports System.IO
Imports System
Imports System.Web.Mail

The last quote from john gave you another import line, but like i said in my first post to you this code is a little dated and you will get some warnings telling you to replace some of the mail code syntax. Once you get the idea how to use this code you can then use the newest definitions. And remember, this code works 100% on my side, just make sure you change or keep the variable names i've put in the code.
 
Back
Top