About.aspx=>
<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="About.aspx.cs" Inherits="About" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table class="style5">
<tr>
<td class="style7">
</td>
<td class="style8">
<asp:Label ID="dsl" Runat="server" ForeColor="#CC0000"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
<strong> To </strong></td>
<td class="style8">
<asp:TextBox ID="t6" runat="server" Width="175px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style7">
<strong> From</strong></td>
<td class="style8">
<asp:TextBox ID="t7" runat="server" Height="23px" Width="176px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">
<strong> Subject</strong></td>
<td class="style8">
<asp:TextBox ID="t8" runat="server" Height="20px" Width="176px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7">
<strong> Body</strong></td>
<td class="style8">
<asp:TextBox ID="t9" runat="server" Height="88px" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style5" colspan="2">
<div>
<strong> Attachment:</strong> <asp:FileUpload
ID="fp0" runat="server" />
<br />
</div>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Button ID="Button2" runat="server" BorderStyle="None" Font-Bold="True"
Font-Italic="True" ForeColor="#990033" onclick="Button2_Click"
Text="Send Email" />
</td>
</tr>
</table>
</asp:Content>
About.aspx.cs=>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.IO;
public partial class About : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
String s = t6.Text;
String[] toId = s.Split(',');
MailMessage mail = new MailMessage();
for (int i = 0; i <= toId.Length - 1; i++)
{
mail.To.Add(toId[i].ToString());
}
mail.To.Add(new MailAddress(t6.Text));
mail.From = new MailAddress("ownEmailid");
mail.IsBodyHtml = true;
mail.Subject = t8.Text;
mail.Body = t9.Text;
SmtpClient smtp1 = new SmtpClient();
smtp1.Host = "smtp.gmail.com";
smtp1.Port = 587;
smtp1.UseDefaultCredentials = false;
smtp1.Credentials = new NetworkCredential("Own Emailid", "pass");
smtp1.EnableSsl = true;
byte[] data = new byte[102400];
//System.IO.MemoryStream stream = new System.IO.MemoryStream(data);
//Attachment attach = new Attachment(stream, "Attachment file name");
//mail.Attachments.Add(attach);
if (fp0.HasFile)
{
mail.Attachments.Add(new Attachment(fp0.PostedFile.InputStream, fp0.FileName));
}
smtp1.Send(mail);
t6.Text = "";
t8.Text = "";
t9.Text = "";
dsl.Visible = true;
dsl.Text = "Message sent.";
}
}