jgira Posted September 19, 2008 Share Posted September 19, 2008 I wrote a script to assist with archiving our project data. As part of the script, I would like it to email me when it is completed (successful or failed). The script works fine. The only issue I am having is that the email that is sent has a sent time 5 hours in the past. For example, when I run the script at 11am, the email I receive has a received time of 11am but a sent time of 5am. I have verified that my PC (the one running this script) has the correct time and is in the correct time zone (Central). I have a feeling it may be the _Date_Time_GetTimeZoneInformation call in the _INetSmtpMail call (INet.au3). Any ideas? I can post the script if that would help but I got the same result using the sample script for _INetSmtpMail in the help file. Thanks in advance... Gira Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 20, 2008 Share Posted September 20, 2008 I wrote a script to assist with archiving our project data. As part of the script, I would like it to email me when it is completed (successful or failed). The script works fine. The only issue I am having is that the email that is sent has a sent time 5 hours in the past. For example, when I run the script at 11am, the email I receive has a received time of 11am but a sent time of 5am. I have verified that my PC (the one running this script) has the correct time and is in the correct time zone (Central). I have a feeling it may be the _Date_Time_GetTimeZoneInformation call in the _INetSmtpMail call (INet.au3). Any ideas? I can post the script if that would help but I got the same result using the sample script for _INetSmtpMail in the help file. Thanks in advance... >_< Gira Just extract that part and see how it works (works fine for me): #include <Date.au3> ; From -- _INetSmtpMail() in the Inet.au3 UDF Local $aResult = _Date_Time_GetTimeZoneInformation() Local $bias = -$aResult[1] / 60 Local $biasH = Int($bias) Local $biasM = 0 If $biasH <> $bias Then $biasM = Abs($bias - $biasH) * 60 $bias = StringFormat(" (%+.2d%.2d)", $biasH, $biasM) ; Debug display, single quotes added to see leading white space ConsoleWrite("Debug: $bias = '" & $bias & "'" & @LF) ; As actually used in the function: ConsoleWrite("Date: " & _DateDayOfWeek(@WDAY, 1) & ", " & @MDAY & " " & _DateToMonth(@MON, 1) & _ " " & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & $bias & @CRLF) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jgira Posted September 22, 2008 Author Share Posted September 22, 2008 (edited) Let me update my initial response... There is a 6 hour difference (which I am sure you can see since the difference from 11 to 5 is 6 hours... ). I ran your code and the results were:Debug: $bias = ' (-0600)'Date: Mon, 22 Sept 2008 10:51:26 (-0600)The date and time looks correct here. I am going to try and put this info into the email itself and see what comes up. Edited September 22, 2008 by jgira Link to comment Share on other sites More sharing options...
jgira Posted September 22, 2008 Author Share Posted September 22, 2008 Ok, just ran the following code: #include <INet.au3> $s_SmtpServer = "VALID SMTP SERVER" $s_FromName = "VALID FROM NAME" $s_FromAddress = "VALID EMAIL ADDRESS" $s_ToAddress = "jgira@wje.com" $s_Subject = "Test Email" Dim $as_Body[2] ; From -- _INetSmtpMail() in the Inet.au3 UDF Local $aResult = _Date_Time_GetTimeZoneInformation() Local $bias = -$aResult[1] / 60 Local $biasH = Int($bias) Local $biasM = 0 If $biasH <> $bias Then $biasM = Abs($bias - $biasH) * 60 $bias = StringFormat(" (%+.2d%.2d)", $biasH, $biasM) ; Debug display, single quotes added to see leading white space $as_Body[0] = "Debug: $bias = '" & $bias & "'" & @LF ; As actually used in the function: $as_Body[1] = "Date: " & _DateDayOfWeek(@WDAY, 1) & ", " & @MDAY & " " & _DateToMonth(@MON, 1) & " " & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & $bias $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body,"","-1") $err = @error If $Response = 1 Then MsgBox(0, "Success!", "Mail sent") Else MsgBox(0, "Error!", "Mail failed with error code " & $err) EndIfThe result is an email received at 10:58AM and sent at 5:58AM (according to the email). The body contains the following:Debug: $bias = ' (-0600)'Date: Mon, 22 Sept 2008 10:58:13 (-0600)Any ideas? Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2008 Share Posted September 22, 2008 The result is an email received at 10:58AM and sent at 5:58AM (according to the email)...I don't get this part.Is this from the header of the mail that you received? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jgira Posted September 22, 2008 Author Share Posted September 22, 2008 Outlook reported the email as received at 10:58 but the header says that it was sent at 5:58. I had run the script at 10:58 so the received time is correct but the sent info (email header) is wrong. So it was a 5 hour difference, not 6. Where are my math skills? Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2008 Share Posted September 22, 2008 Outlook reported the email as received at 10:58 but the header says that it was sent at 5:58. I had run the script at 10:58 so the received time is correct but the sent info (email header) is wrong.So it was a 5 hour difference, not 6. Where are my math skills? Aha!!!Mail usually passes through few servers till final destination. Maybe you are not reading it right. Maybe that time input is from other server located in different time zone. Check it again? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jgira Posted September 23, 2008 Author Share Posted September 23, 2008 I am using our Exchange server as the SMTP server and my email account on the same server is the account I am sending to. I don't think I am hopping through any other email servers. I also just verified that all of our email servers are in the correct timezone and have the correct time. They all do. Link to comment Share on other sites More sharing options...
metris Posted November 25, 2008 Share Posted November 25, 2008 I have exactly the same problem. Have anybody already a solution? Link to comment Share on other sites More sharing options...
jgira Posted December 3, 2008 Author Share Posted December 3, 2008 I am still having this problem. Did a test and sent an email that displayed the time. The time I sent in the body was 8 hours ahead of the sent time displayed. Does anyone have any ideas? Link to comment Share on other sites More sharing options...
trancexx Posted December 3, 2008 Share Posted December 3, 2008 I am still having this problem. Did a test and sent an email that displayed the time. The time I sent in the body was 8 hours ahead of the sent time displayed. Does anyone have any ideas?Post e-mail header here along with send/receive times that you have. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jgira Posted December 4, 2008 Author Share Posted December 4, 2008 Attached is a screenshot of the email in question... The only thing I altered in this image is the email address. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 4, 2008 Share Posted December 4, 2008 Attached is a screenshot of the email in question... The only thing I altered in this image is the email address.And the timezone of your workstation AND your mail server are set correctly (not just the time, the time zones)? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted December 4, 2008 Share Posted December 4, 2008 @jgira That is interpreted header. Real header is needed. Right click on message in inbox list and choose "Message Options..." or whatever. Window that pop-up will have true header. Post that. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
cbruce Posted December 4, 2008 Share Posted December 4, 2008 (edited) Somewhere in the UDF it is getting the current time for inserting into the email header. The Inet function that ends up getting called (with that current time) is expecting the time in UDT. But the time is being passed to the Inet function as CT (5 hour CDT difference back in your original entries in September - 6 hour difference now that you are back on CST). So the UDF is either getting and passing the LOCAL time to the Inet function... or it is getting the SYSTEM UDT time and converting it (with the bias) to LOCAL time before passing it to the Inet function. Either way - it is incorrect in doing so. Bruce Edited December 4, 2008 by cbruce Link to comment Share on other sites More sharing options...
jgira Posted December 4, 2008 Author Share Posted December 4, 2008 Received: from IS-L08-050 (10.1.8.54) by {Valid SMTP Server} (10.4.20.101) with Microsoft SMTP Server id 8.1.291.1; Thu, 4 Dec 2008 09:45:24 -0600From: LANDesk - Workstation Imaged {Vaild Email Address}To: <jgira@wje.com>Subject: Computer ReImaged - IS-L08-050MIME-Version: 1.0Date: Thu, 4 Dec 2008 09:45:24 +0000Content-Type: text/plain; charset="US-ASCII"Message-ID: <ea3a6748-4a9b-4190-9814-c503bb8dc44c@wjenbcas1.wje.com>Return-Path: {Vaild Email Address}Obviously, I replaced the from email address and smtp server... Link to comment Share on other sites More sharing options...
jgira Posted December 4, 2008 Author Share Posted December 4, 2008 And the timezone of your workstation AND your mail server are set correctly (not just the time, the time zones)? Yes, the timezone on all the pc's involved is correct. Link to comment Share on other sites More sharing options...
trancexx Posted December 4, 2008 Share Posted December 4, 2008 Obviously, I replaced the from email address and smtp server...That is not header of the mail sent using function _INetSmtpMail()Why are you posting that?Do you have issue with _INetSmtpMail() from INet.au3 or what? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 5, 2008 Share Posted December 5, 2008 Yes, the timezone on all the pc's involved is correct.Sorry to press the point, but that's only answers half the question. What about the time zone on the mail server? It only gets handled correctly if the zones are set correctly on BOTH the clients and the servers. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jgira Posted December 5, 2008 Author Share Posted December 5, 2008 Obviously, I replaced the from email address and smtp server...That is not header of the mail sent using function _INetSmtpMail()Why are you posting that?Do you have issue with _INetSmtpMail() from INet.au3 or what?Actually, this is. It might not be from the very email I posted earlier, but it is from a similiar email with the same problem. So, to answer your question, yes I am having a problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now