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.
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.
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