C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

date functions....


Posted Date: 02 Sep 2008      Posted By: sujibala      Member Level: Gold     Points: 1   Responses: 5





hi friends,

i want solve 2 problems,

first one:i want display date in thes format(02-sep-2008);i used this code(d=dd-MMM-yyyy);but date can't be display

another one:

i want send single message to many emailid;alreay i stored emailid in table

so how to send email to many user

Pl give me friends

Regards
suji






Responses

Author: manoj    02 Sep 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

hai

if u are fetching a date from database
means just u fetch a date in this format
convert(varchar(12),Date(databsefieldname),103) as Date



Author: Karthikeyan S    02 Sep 2008Member Level: GoldRating: 3 out of 53 out of 53 out of 5     Points: 3

Hi,

1. Whether you used the .ToString() function to format the datetime variable. If so it should work compulsarly else you have did some other mistake.

Syntax for this is:
String lstrDate = ldateLoggedInDate.ToString("dd-MMM-yyyy");

2. Get data from database to a datatable.

a. Get data from database to a datatable:
query for this 'SELECT Email_ID FROM EMAIL_TABLE'
and use the dataadapter and fill the datatable "ldtEmailIDs".

b. use foreach loop and concatenate each email ids.

System.Net.Mail.MailMessage newEmail = new System.Net.Mail.MailMessage();
// or you can use smtp email also ur choice.

foreach(DataRow ldr in ldtEmailIDs.Rows)
{
//newEmail.To.Add("abcd@abcd.com");
newEmail.To.Add(ldr[0].ToString()); // in this way get emailids from //db and add it to "To" object of email object.
}

...
your code follows.



Author: sweety    02 Sep 2008Member Level: SilverRating: 3 out of 53 out of 53 out of 5     Points: 3

protected void ButtonSubmit_Click(object sender, System.EventArgs e)
{
Server.ScriptTimeout = 1000;
Response.Flush();

SmtpMail.SmtpServer = "localhost";
MailMessage mail = new MailMessage();
mail.To = this.TextBoxTo.Text;
mail.Cc = this.TextBoxCc.Text;
mail.Bcc = this.TextBoxBcc.Text;
mail.From = this.TextBoxFrom.Text;
mail.Subject = this.TextBoxSubject.Text;
mail.Body = this.TextBoxBody.Text;

try
{
SmtpMail.Send(mail);
Response.Write("The Mail has been sent to: ");
Response.Write(mail.To);
Response.Write(mail.Cc);
Response.Write(mail.Bcc);
}
catch(System.Exception ex)
{
Response.Write(ex.Message);
}

Response.Flush();
}

Points of Interest



Author: Sabu C Alex    03 Sep 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

hai

DateTime dt = DateTime.Now;
String dte = dt.ToString("dd-MMM-yyyy");

Hope this will help you
Sabu



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : No connection could be made because the target machine actively refused it
Previous : preview of pdf file is not coming in PrintPreviewControl
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use