Jump to content

How to make a Email Client/Sender

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
haxftw

haxftw

    Newbie

  • Members
  • Pip
  • 2 posts
Hello, Today i will be showing you how to create a email sender!
Its really simple, and then i mean.. simple


Start by Creating a new Window Forms Application

When you have done that, you will have a blank form, Double click the form so the coding page shows and add the folowing code over Public Class Form1

Imports System.Net.Mail

When you have done that and you have no errors, continue.


Okey, so we will need 4 textboxes and 4 labels + one button

Lets start with the first one!

Add one Textbox and a Label, rename the label to "From" and place the textbox right after it

then take the second textbox and the second label, rename it to "To" and place the textbox right after the label.

Now place the third textbox and the third label, rename it to "Subject"

Now at last, place the fourth textbox and the fourth label, rename the label to "Text" or "Enter message here". Make the fourth textbox multi line

Now just add one button, change the text to "Send"

Here Starts coding----------------------------------

Okey, double click the button and add the folowing code:

Dim smtpServer As New SmtpClient()

        Dim mail As New MailMessage()

        smtpServer.Credentials = New Net.NetworkCredential("killerdwrf@gmail.com", "wertyl11")

        'using Gmail

        smtpServer.Port = 587

        smtpServer.Host = "smtp.gmail.com"

        smtpServer.EnableSsl = True

        mail = New MailMessage()

        mail.From = New MailAddress("killerdwrf@gmail.com" , textbox1.text)

        mail.To.Add(textbox2.text)

        mail.Subject = textbox3.text

        mail.Body = textbox4.text

        smtpServer.Send(mail)

where it stands "("killerdwrf@gmail.com", "wertyl11")", you can ignore them, only change them if you dont wanna use my gmail account, remember this is not necessary!

Coding ends here ----------------------------------

Now debug your program, it you have any problems, please post them on the thread

Please say thanks if this works!

I am new here, and please ignore my spelling mistakes

#2
giv3mesmile

giv3mesmile

    Newbie

  • Members
  • PipPip
  • 14 posts
uhm i have couple errors :S

Quote

Error 1 Type 'SmtpClient' is not defined
Error 2 Type 'MailMessage' is not defined.
Error 4 Type 'MailAddress' is not defined.


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Did you include the import statement?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
giv3mesmile

giv3mesmile

    Newbie

  • Members
  • PipPip
  • 14 posts
yeah :S

Quote

Private Sub SendEmail(
ByVal MailFrom As String, _
ByVal MailPass As String, _
ByVal MailTo As String, _
ByVal MailSubj As String, _
ByVal MailText As String, _
ByVal MailFromName As String, _
ByVal MailToName As String, _
Optional ByVal MailAttach As String = "")

now it cant complete it , can u see the mistake? something is missing im afraid

#5
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
I'll try this out when I get home!
Thanks For This!

#6
D0m1313

D0m1313

    Newbie

  • Members
  • Pip
  • 3 posts
Haha im trying this right now!

#7
D0m1313

D0m1313

    Newbie

  • Members
  • Pip
  • 3 posts
how to send the information to the email?