Sign in to follow this  
Followers 0
jgira

_INetSmtpMail Sent Time Info

38 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by jgira

Share this post


Link to post
Share on other sites

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) 
EndIf

The 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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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? :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

:)

Share this post


Link to post
Share on other sites

I have exactly the same problem.

Have anybody already a solution?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Attached is a screenshot of the email in question... The only thing I altered in this image is the email address.

post-16034-1228403818_thumb.jpg

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

#15 ·  Posted (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 by cbruce

Share this post


Link to post
Share on other sites

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 -0600

From: LANDesk - Workstation Imaged {Vaild Email Address}

To: <jgira@wje.com>

Subject: Computer ReImaged - IS-L08-050

MIME-Version: 1.0

Date: Thu, 4 Dec 2008 09:45:24 +0000

Content-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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0