Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to send mail in VB.net For that I wrote following code

imports System.net.mail

Dim mailclient As SmtpClient = New SmtpClient("MMEX-mailbox"", 25)
mailclient.Send("xyz@mail.com", "abc@mail.com", "Hi", "Hello")


But while running code it will give exception that"mail sending failed"

why such happen anything more require to import or to connect something
or any component is not installed on my computer? What is the problem???
plz tell me anyone know
Thanx in Advance
Posted

1 solution

You need to add info about SMTP in your Web.config file:

XML
<configuration>
  <!-- Add the email settings to the <system.net> element -->
  <system.net>
    <mailSettings>
      <smtp>
        <network 
             host="relayServerHostname" 
             port="portNumber"
             userName="username"
             password="password" />
      </smtp>
    </mailSettings>
  </system.net>
  <system.web>
    ...
  </system.web>
</configuration>


Follow the links for more details:
Sending Email in ASP.NET 2.0 [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900