Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2006, 02:33 AM
Authorized User
 
Join Date: Jul 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET 2.0 Email Problem-Urgent

ls help me. In my website www.usssolutions.com I have create a form for Feedback but i'm not able to send email through that form.
My Code is:

Imports system.Net.Mail
Dim msg as MailMessage
            msg = New MailMessage
            Dim obj As New SmtpClient("mail.usssolutions.com",25)
            msg.From = New MailAddress(txtfrom.text)
            msg.To.Add(New MailAddress("[email protected]"))
            msg.Subject = txtsubject.Text
            msg.Body = txtmessage.Text
            msg.IsBodyHtml = False
            obj.Send(msg)

Pls give ur kind advice.

 
Old September 22nd, 2006, 05:15 PM
Authorized User
 
Join Date: Apr 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

Are you getting an error? If so, what is the error?

Troubleshooting life: 1 bug at a time.
 
Old September 29th, 2006, 09:57 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

Try this code (I've taken some bits out of my code, which is why SQLClient is in there, it retrieves the email from the users record)

Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Mail

Partial Class ContactUs
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' ---------------------------------------------------------------------------
        ' Send an email
        ' ---------------------------------------------------------------------------

        Dim Email As String
        Dim sBody As String
        Dim Msg As Net.Mail.MailMessage = New Net.Mail.MailMessage()
        Dim MailObj As New Net.Mail.SmtpClient()

        sBody = "The following message was sent from the Contact Us page"

        Email = "[email protected]"

        Msg.From = New Net.Mail.MailAddress("[email protected]", "Your Friendly Name")
        Msg.To.Add(New Net.Mail.MailAddress(Email))
        Msg.IsBodyHtml = "True"
        Msg.Body = sBody
        Msg.Subject = "Contact Us Message"

        Try
            MailObj.Send(Msg)
        Catch ex As Exception
            Response.Write(ex.Message) 'Write error message
            Exit Sub
        End Try

        MsgBox("Thank you for sending your message - We will deal with this as soon as possible")
' Or Divert to a thank you page.

    End Sub
End Class




------------------------------------------------------------------

Also in the Web.Config File


<system.net>
<mailSettings>
<smtp deliveryMethod="network" from="[email protected]">
<network host="mail.yourhost.com" userName="yourusername" password="xxxxx" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>

-----------------------
Good Luck
 
Old October 6th, 2006, 11:19 PM
Authorized User
 
Join Date: May 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem may be that you are not providing the credentials information.
may this blog help you!!!

http://apnasaathi.blogspot.com/2006/...sing-smtp.html

rajkumar sharma





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem reciving email Urgent marshad77 Apache Tomcat 1 July 24th, 2008 06:28 AM
HTML email problem in asp.net sanjivbshinde ASP.NET 2.0 Professional 5 May 29th, 2008 06:49 AM
Problem with javascript in asp.net appl-URGENT sunithavasudevan ASP.NET 1.0 and 1.1 Professional 1 October 24th, 2006 03:07 PM
Com Interoperability problem(ASP.NET)Urgent deeptisingh20 General .NET 2 January 19th, 2006 08:34 AM
email problem in asp.net raju_30339 ASP.NET 1.0 and 1.1 Basics 1 February 8th, 2005 09:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.