Thanx for the reply actually i have website in which i need to add one funtion like retreiveing data from the database and sending email to the retreived member from the database. Could you tell how can i write code in console application and send email using that and how can i integrate this console application in my website?
Want to execute function in our website automatically
Hii i want to to execute one function automatically on first date of each month in my website.To implement this what i should do. means where i should write the code to implement this?
Posted Oct 11, 2010, 1:00 AM
Instead of doing it in asp.net , better you can write console application and schedule it by using windows scheduler.
Can you explain your requirement litte more ?
Posted Oct 11, 2010, 2:18 PM
http://www.iopus.com/guides/winscheduler.htm
http://support.microsoft.com/kb/308569
swati shrivastavaPosted Oct 11, 2010, 7:19 AM
{
///do your db operation here. then call the sendMail funtion
SendMail("DB Details info")
}
how and from where i could call this function automatically once in a month i.e, "GetDbDetails()"
Posted Oct 11, 2010, 2:57 AM
{
///do your db operation here. then call the sendMail funtion
SendMail("DB Details info")
}
private void SendMail(string MailDetails)
{
// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
// System.Net.Mail.SmtpClient is the alternate class for this in 2.0
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "localhost";
//Default port will be 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("[email protected]");
message.Subject = "Feedback";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("[email protected]")
message.CC.Add("[email protected]");
message.CC.Add("[email protected]");
// You can specify Address directly as string
message.Bcc.Add(new MailAddress("[email protected]"));
message.Bcc.Add(new MailAddress("[email protected]"));
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
// Message body content
message.Body = MailDetails;
// Send SMTP mail
smtpClient.Send(message);
lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "Send Email Failed." + ex.Message;
}
}
Please refer the following links also.
http://www.codeproject.com/KB/aspnet/EmailApplication.aspx
http://www.4guysfromrolla.com/articles/072606-1.aspx
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
http://www.codeproject.com/KB/vb/SendMail.aspx
Hope this helps you.
swati shrivastavaPosted Oct 11, 2010, 1:16 AM