Wow - talk about old threads! Blow the dust off this one.
Anyway, I've been using the above clipper code but the "Date:" field data sometimes throws off some mail recipients because their mail servers/clients don't know how to interpret it (and I have had some complaining customers - gotta keep em happy). Basically its not
RFC 2822 compliant. So I wrote this code to return the current (and compliant format) UTC (GMT) date time so I don't have to worry about timezone differences, etc. It calls an external website to get and parse the UTC, so use at your own risk.
Specifically change:
Code: Select all
send("Date:" + FormatDate("%dd/%mm/%yyyy @ %hh:%ii:%ss", Date()) )
to:
using the code below.
If your outgoing mail server is in GMT, then change the "-0000" to "+0000" to really be RFC compliant.
Code: Select all
Procedure.s OpenURL(pUrl.s,pOpenType.b)
; OpenURL procedure by ricardo 2003
Protected isLoop.b, INET_RELOAD.l, hInet.l, hURL.l, Bytes.l
Protected buffer.s, res.s
isLoop.b=1
INET_RELOAD.l=$80000000
hInet.l=0: hURL.l=0: Bytes.l=0
buffer.s=Space(2048)
hInet = InternetOpen_("PB@INET", pOpenType, #Null, #Null, 0)
hURL = InternetOpenUrl_(hInet, pUrl, #Null, 0, INET_RELOAD, 0)
Repeat
Delay(1)
InternetReadFile_(hURL, @buffer, Len(buffer), @Bytes)
If Bytes = 0
isLoop=0
Else
res.s = res + Left(buffer, Bytes)
EndIf
Until isLoop=0
InternetCloseHandle_(hURL)
InternetCloseHandle_(hInet)
ProcedureReturn res
EndProcedure
Procedure.s ParseTagValue(pString.s,pStartTag.s,pEndTag.s)
Protected lRetVal.s, lPos1.l, lPos2.l
lRetVal.s = ""
lPos1.l = FindString(pString.s,pStartTag.s,1)
If (lPos1.l > 0)
lPos2.l = FindString(pString.s,pEndTag.s,lPos1.l)
If (lPos2.l > 0)
lPos1.l = (lPos1.l + Len(pStartTag.s))
lRetVal.s = Mid(pString.s,lPos1.l,(lPos2.l - lPos1.l))
EndIf
EndIf
ProcedureReturn lRetVal.s
EndProcedure
Procedure.s GetUTC()
Protected lRetVal.s, lUrl.s, lUrlResult.s, lPos1.l, lPos2.l
Protected lFirstString.s, lSecondString.s, lThirdString.s, lFourthString.s
Protected lMonth.s, lDay.s, lTime.s, lMonthInt.l, lParseResult.s, lDow.s, lYear.s
lRetVal.s = ""
lUrl.s = "http://www.time.gov/timezone.cgi?UTC/s/0"
lFirstString.s = "<td align=" + Chr(34) + "center" + Chr(34) + "><font size=" + Chr(34) + "7" + Chr(34) + " color=" + Chr(34) + "white" + Chr(34) + "><b>"
lSecondString.s = "<br>"
lThirdString.s = "</b></font><font size=" + Chr(34) + "5" + Chr(34) + " color=" + Chr(34) + "white" + Chr(34) + ">"
lFourthString.s = "<br>"
lUrlResult.s = OpenUrl(lUrl.s,1)
lUrlResult.s = Trim(lUrlResult.s)
If (Len(lUrlResult.s) > 0)
lTime.s = Trim(ParseTagValue(lUrlResult.s,lFirstString.s,lSecondString.s))
lParseResult.s = Trim(ParseTagValue(lUrlResult.s,lThirdString.s,lFourthString.s))
;Debug lTime.s
;Debug lParseResult.s
If ((Len(lTime.s) > 0) And (Len(lParseResult.s)))
lDow.s = Left(lParseResult.s,3)
lMonth.s = Left(StringField(lParseResult.s,2," "),3)
lDay.s = Trim(StringField(lParseResult.s,3," "))
lDay.s = Mid(lDay.s,1,Len(lDay.s) - 1)
lYear.s = Trim(StringField(lParseResult.s,4," "))
lRetVal.s = lDow.s + ", " + lDay.s + " " + lMonth.s + " " + lYear.s + " " + lTime.s + " -0000"
EndIf
EndIf
ProcedureReturn lRetVal.s
EndProcedure
Debug GetUTC()
Cheers!