Hello frens,
I am new to ASP.Net and I am trying to create an application where I want to send my form contents to my email ID. I used the 2 approaches.

1) HTML form:

<form  enctype="multipart/form-data" runat=server action="mailto:abcd@efgh.com" method="post">
<p>Enter your name below:<br />
<input type="text" name="names" size="100" /></p>
<p><input type="submit" value="Submit Feedback" /><br />
<input type="reset" value="Reset Feedback" /></p>
</form>

While the above code does send me a email with the name entered in the text box "text1", it open MS Outlook when I click on "Submit" button and there I have to again click the Send Button in the Outlook Window. Is there anyway that I can send an email directly just by clicking the Submit button once rather than having to send through Outlook? Something like as soon as I click on the Submit button on my form, it send a email and gives a confirmation that the message was sent.

2) ASP.Net namespace System.Web.Mail:

using System.Web.Mail;
public partial class email : System.Web.UI.Page
{
 protected void Page_Load(object sender, EventArgs e)
    {
      SmtpMail.Send("abcd@efg.com", "ijkl@mnop.com", "Hiiiii", "body text here");
Response.Write("Success..!");
    }
}

This approach does not work at all. It gives me the following exception.
System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Do I need to give some SMTP server destination?

Please help...!

Thanks
Sharon.

hi,

which version of asp.net r u using.
where did u declare smtpmail

I am using ASP.Net 3.0. Do I have to declare? I included the namespace System.Web.Mail

SmtpMail is a class in that namespace and Send is a method. So thats how I used it. If you have any other suggestions, that would help.

Thanks
Sharon.

hi,

check this code.you have to add name space

imports system.net.mail
sub sendmail()
        Dim msg As New MailMessage
        msg.From = txtEmail.Text
        msg.To = "info@some.co.in"
        'msg.To = "n@yahoo.com"
        msg.Bcc = "n@some.co.in"
        msg.Subject = " Demo Info "
        msg.BodyFormat = MailFormat.Html
        Dim str As String
        msg.Body = mail(str)
        msg.Priority = MailPriority.High
        Try
            SmtpMail.SmtpServer = "localhost"
            SmtpMail.Send(msg)
        Catch ex As HttpException
        Catch ex As Exception
        Finally
        End Try
    End Sub

You should Specify your SmtpServer as following:
SmtpMail.SmtpServer = "abc"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.