Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

Send an E-Mail from Client to Server in 2.0

Author: Zunnair

Sometimes We need To Add Send Mail Link To Our Forms which helps to mail the Current Reports or Information to Destination Mail Address.

Sending Mail from a Client


To send mail using the client' s mail system, create a hyperlink using the mailto protocol. For example, the following HTML shows a hyperlink that creates a new message with a subject line and a short message body.


<A href=" SUBJECT = Sending from a client& BODY = Some message text." />

When the use clicks the preceding hyperlink, the client' s browser starts the client' s mail application and creates a message. You can use the mailto protocol in place of  any destination URL in a server control or an  HTML control. For instance, the following HTML defines a Hyperlink server control that sends a mail message.

<asp:HyperLink ID="hypMail" NavigateUrl=" SUBJECT = Mailing a Webform & BODY = Some message text." Runat="server">Send Email </asp:HyperLink>


Sending Mail from the Server


When you send mail from the server, ASP.NET does not start the client’s mail system to allow the user to compose the message to send, to add attachments, or to validate addresses. Instead, you compose the message in code and send it one of two ways:


  • You can send a simple message using the SMTPMail class’s Send method.
  • You can create a more complex message using the MailMessage class, and then send that message using the SmtpMail class’s Send method.


Both the SMTPMail class and the MailMessage class are part of the System.Web.Mail namespace in the .NET Framework, so add the following statement at the beginning of your module to simplify references to those classes in code.


Imports System.Web.MailPrivate

Sub butMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butMail.Click

'Create the message.

Dim mailNew As New MailMessage()

'Set the message properties.

mailNew.From = ""

mailNew.To = ""

mailNew.Subject = "This is the subject text."

mailNew.Body = "This is the message text."

'Create an attachment.

Dim atcItem As New MailAttachment(Server.MapPath(Request.ApplicationPath) & "\joey.jpg")

'Attach it to the message.


'Send the message.


End Sub


Add Article Comment:
Name :
Email Address :
Comments :
<< Working with XMLDocument Class using VB.Net

Disclaimer - Privacy
© 2002-2018