Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with sending email from ASP.NET (VS2010)

Hi,

I am using the code below to send an email, although i don't receive an error, the message was not sent, any ideas what is wrong? I am using the development server that comes with VS2010.

 Try
            Dim Message As MailMessage = New MailMessage()
            Dim Smtp As New SmtpClient()
            '-- Build Message
            Message.From = New MailAddress("Vchsc@yahoo.com", "vcnyuh")
            Message.To.Add(New MailAddress("vcarlos@hotmail.com", "Victor"))
            Message.IsBodyHtml = False

            Message.Subject = "Come on My Show Soon"
            Message.Body = "Please be a guest on my show. - Larry"
            '-- Send Message
            '-- each web host is different
            '-- (adjust next 2 lines accordingly)
            Smtp.Host = "localhost"
            Smtp.Port = "50448"

            Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
            Smtp.Send(Message)

            ''     MsgBox("Message Sent")

            'Your code here

        Catch ex As Exception
            Console.WriteLine(ex.InnerException)
            Console.WriteLine(ex.StackTrace)
        End Try
ASKER CERTIFIED SOLUTION
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Victor  Charles

ASKER

Hi,

Thanks for the link, do you know a link using vb.net? I tried modifying the code below  to VB.NET but it still does not work. Could the issue be because I am using the development server that comes with VS2010?

Try
            Dim Message As MailMessage = New MailMessage()
            Dim Smtp As New SmtpClient("smtp.gmail.com")
            '-- Build Message
            Message.From = New MailAddress("vcarlos@Gmail.com")
            Message.To.Add(New MailAddress("victor_carlos@hotmail.com"))
            Message.IsBodyHtml = False
            Message.Subject = "Come on My Show Soon"
            Message.Body = "Please be a guest on my show. - Larry"
            '-- Send Message
            '-- each web host is different
            '-- (adjust next 2 lines accordingly)
            Smtp.Host = "localhost"
            Smtp.Port = "99999"

            '*********************

            Smtp.Credentials = New System.Net.NetworkCredential("vcarlos", "psswd$$")
            Smtp.EnableSsl = True
            '***************
            Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
            Smtp.Send(Message)
            ''     MsgBox("Message Sent")
            'Your code here
        Catch ex As Exception
            Console.WriteLine(ex.InnerException)
            Console.WriteLine(ex.StackTrace)
        End Try
Hi,
As I have mentioned, "localhost" is not a valid smtp server. You'll have to manage to have a smtp server on your machine/network in order to make it run.
Hi,

Does it come with IIS? If not is it a free download that can be easily configured in IIS?

Thanks,

Victor
Hi, you can have a look at
http://forums.iis.net/p/1157046/1901343.aspx

but this is valid for Windows Server products not desktop ones.
Thanks!