954,160 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Email Application

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:
<input type="text" name="names" size="100" /></p>
<p><input type="submit" value="Submit Feedback" />
<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.

anitha joe
Light Poster
25 posts since May 2008
Reputation Points: 4
Solved Threads: 0
 

hi,

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

greeny_1984
Posting Whiz
372 posts since Apr 2007
Reputation Points: 25
Solved Threads: 29
 

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.

anithajoe
Newbie Poster
9 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

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
greeny_1984
Posting Whiz
372 posts since Apr 2007
Reputation Points: 25
Solved Threads: 29
 

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

brightline
Junior Poster in Training
60 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You