471,326 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 software developers and data experts.

sent time incorrect

Hello,
I wrote this program in C# that accesses a SQL Server database that
runs a stored procedure and sents the results in an email every 30min.
I wrote this as a windows application instead of a windows service, so
the application is run every 30min through a scheduled task. When the
email is received the received time is ok, but the sent time is
incorrect. In some emails the sent date/time is the same displaying
that the email was sent yesterday, but the latest one showed it was off
by 9 and a half hours. The date and time on the computer this is
running from is correct as is the exchange server and the computer it's
running on. The network admin said the time is handled by the domain
controller so if the time is off emails would not be sent at all.
Anyone have any ideas as to why this is occuring or how to fix it? Is
there something I need to write in my code to get the sent date/time to
appear correctly? Below is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Net.Mail;

namespace Harland_Email_Report
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
SqlConnection Conn = new SqlConnection();
{
Conn = new SqlConnection("server=***;user
id=***;password=***;database=***");
Conn.Open();
}

string emailbody = string.Empty;
emailbody = "<table width=599px><tr
align=center><th>Department</th><th># Molds</th><th># Stamps</th><th>#
Rejected</th><th> # Total</th></tr>";

SqlCommand DBCmd = new
SqlCommand("sp_Mold_Header_SEL_ByDepartmentDueDate ", Conn);
DBCmd.CommandType = CommandType.StoredProcedure;

SqlDataReader myDataReader;
myDataReader = DBCmd.ExecuteReader();

while (myDataReader.Read())
{
emailbody = emailbody + "<tr align=center><td>" +
myDataReader["Department"].ToString() + "</td><td>" +
myDataReader["Number of Molds"].ToString() + "</td><td>" +
myDataReader["Number of Stamps"].ToString() + "</td><td>" +
myDataReader["Stamps Rejected"].ToString() + "</td><td>" +
myDataReader["Total Number of Stamps"].ToString() + "</td></tr>";
}

emailbody = emailbody + "</table>";
MailMessage mm = new MailMessage();
mm.To.Add("te**@test.com");
mm.From = new MailAddress("te**@test.com");
mm.Subject = "subject";
mm.BodyEncoding = Encoding.ASCII;
mm.IsBodyHtml = true;
mm.Body = emailbody;
SmtpClient client = new SmtpClient("***");
client.Send(mm);

Conn.Close();

this.Close();

}
}
}

thanks

Nov 28 '05 #1
1 1503
hal
anybody have any ideas?

Nov 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.