EMAIL

I am using this code in vb.net 2005 to sent an email but an error FAILURE SENDING MAIL is allways appearing. Can someone show me where I am duing wrong.

Try

Dim SmtpClient As New System.Net.Mail.SmtpClient

SmtpClient.Host = "localhost"

SmtpClient.Port = 25

SmtpClient.UseDefaultCredentials = True

SmtpClient.Send("glennzarb@gmail.com", "glenn_zarb@hotmail.com", "Test", "hi")

MsgBox("sent")

Catch ex As Exception

MsgBox("Send failure:" & ex.Message)

End Try


I haven't installed any other programs or smpt's


Answer this question

EMAIL

  • The Emerald Knight

    Do you have the smtp service installed


  • Wendell G

    it all depends if the email provider allows you to send emails through them programmatically, and if so, they will give you/have instructions about using their SMTP server.

    For example, my web hosting provider allows emails to be sent through them through an SMTP server, they gave me all the details required to send emails through them programmatically - the same thing would apply for any email service provider - only if they allow/support users sending emails through their servers programmatically rather than through their web/client based email system



  • we7313

    the code is pretty much the same as you have done, except replacing the email address and SMTP server address details etc...

    I use mine to send emails from my ASP.NET website using the System.Web.Mail class (MailMessage/SMTP classes) however it uses pretty much the same procedure/methods to send out an email.

    Simply put - the code you have posted is correct. All you need now is an SMTP service which allows you to send emails using the SMTP server details.



  • Suhask

    Which email service are you using

  • Buddhist

    Can you tell me another email service which allows me to do so Is gmail good

  • naguaramipana

    Can you give me the code you used to send an email please

  • VBGMan

    NO. What is the SMTP service

  • RickGaribay.NET

    It is the service for sending emails from a local computer. You can change the host name to the name of your email server you use with your email program.


  • Jimmy_fingers

    I kept it like this SmtpClient.Host = "localhost" and it is still telling me FAILURE SENDING MAIL with the smtp service installed

  • Mojosound

    When I remove the host an error occurs (The SMTP was not specified)

  • Jweige

    Again, it does not matter about the email service that a person is using but rather if the email service provider supports/allows its customers/users to send emails programmatically via their SMTP servers.

    However in regards to the question, I use my own website email services, provided by my web hosting provider to send out any emails I wish to programmatically.



  • Keith Newton

    you cannot use hotmail to send emails via this method. you need to either:

    1) setup your own SMTP service using IIS and configuring it

    2) use some other email service which allows you to use their SMTP server to send email through



  • Docpro777

    I would get rid of the lines of code setting the host, port, and usedefaultcredentials and try it again


  • O11y

    What must SmtpClient.Host = " " be I using the hotmail account to send emails.

  • EMAIL