How to do automail without database?

hello Friends...

I am trying to send email on button click and i did it sucessfully...

but now i am try to autorespond of same mail.. here i will define my problem..

my aspx page code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page











And my aspx.cs page code:-

protected void BtnEmail_Click(object sender, EventArgs e)
{


MailMessage mail = new MailMessage();


mail.To.Add("name@mydomain.com");


mail.From = new MailAddress("name@mydomain.com");



mail.Subject ="Test";

mail.IsBodyHtml = true;
mail.Body = "
Subscribe NewsLetter to " + TxtEmail.Text.Trim() +"
";

SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp1.mail.pw";
smtp.Credentials = new System.Net.NetworkCredentia("name@mydomain.com","xyzqwe");
smtp.Send(mail);

}

From these codes i can sent mail..

but now i need to create auto reply to subimmited email id i.e .. Requester submit his/her email id here.. i will get the mail for newsletter subscription and requester will have to recieve one confirmation mail too form my id...

i tried one code for this but didnt do it.. example of that code is same..

ex:-

protected void BtnEmail_Click(object sender, EventArgs e)
{


MailMessage mail = new MailMessage();
string Request = "Request";

mail.To.Add("name@mydomain.com");


mail.From = new MailAddress("name@mydomain.com");



mail.Subject ="Test";

mail.IsBodyHtml = true;
mail.Body = Request;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp1.mail.pw";
smtp.Credentials = new System.Net.NetworkCredential("name@mydomain.com","xyzqwe");
smtp.Send(mail);




MailMessage mail1 = new MailMessage();
string Reply = "TEST COMPLITE";
mail1.To.Add("TxtEmail.Text");

mail1.From = new MailAddress("name@mydomain.com");
mail1.Subject = "TestAccomplish";
mail1.IsBodyHtml = true;
mail.Body = Reply;
SmtpClient smtp1 = new SmtpClient();
smtp1.Host = "smtp1.mail.pw";
smtp1.Credentials = new System.Net.NetworkCredential("name@mydomain.com", "xyzqwe");
smtp1.Send(mail);
}

it shows me error that mail1.to.add does not accept string.. so help me how can i do this ..

and please don tell meto use database beacuse i am not using database for this project...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories