Author | Topic: MimeMessage DATE header | |
---|---|---|
Frans Vermeulen | MimeMessage DATE header on Thu, 06 Mar 2008 16:59:48 +0100 When I send emails using SmtpClient, my date: header field is sent corrupted ie.: it is sent as: "Date: Date: Thu, 6 Mar 2008 16:40:23 +0100" Note the double designator "Date: " When I try to correct it oMimeMessage:GetHeader("DATE") returns NIL and oMimeMessage:SetHeader("DATE", Left(CDoW(Date()), 3)+; ", "+Var2Char(Day(Date()))+" "+Left(cMonth(Date()), 3)+" "+; Var2Char(Year(Date()))+" "+Time()+" +0100") does not seem to work. Asinet 1.90.331.0 Has anyone have the same experience, and is there a solution? Regards, Frans Vermeulen | |
Andreas Gehrs-Pahl | Re: MimeMessage DATE header on Fri, 07 Mar 2008 03:59:07 -0500 Frans, >When I send emails using SmtpClient, >my date: header field is sent corrupted ie.: >it is sent as: >"Date: Date: Thu, 6 Mar 2008 16:40:23 +0100" >Note the double designator "Date: " Yes, the Date header has been broken for ever. Originally, ASINet didn't set the date at all (PDR 5069) and now it apparently doesn't do a very good job when setting it. >Has anyone have the same experience, and is there a solution? I have written my own routine to set this header. I also received a (wish list) PDR to allow the setting of this header in a user-friendly way (PDR 5312), but so far nothing has materialized. > When I try to correct it > oMimeMessage:GetHeader("DATE") returns NIL > and > oMimeMessage:SetHeader("DATE", Left(CDoW(Date()), 3)+; > ", "+Var2Char(Day(Date()))+" "+Left(cMonth(Date()), 3)+" "+; > Var2Char(Year(Date()))+" "+Time()+" +0100") > does not seem to work. As there is no "Date:" header, I always Add one, doing the following: LOCAL oEMail := MIMEMessage():New() [...] oEMail:AddHeader("Date", INetDate(cDateTime)) [...] Function INetDate(cDTStamp) LOCAL dINetDate := iif(cDTStamp == NIL, Date(), StoD(left(cDTStamp, 8))) LOCAL cINetTime := iif(cDTStamp == NIL, Time(), substr(cDTStamp, 9, 8)) LOCAL cINetDate := DtoC(dINetDate) LOCAL cINetDoW := left(NtoCDoW(DoW(dINetDate)), 3) LOCAL cINetDay := StrZero(Day(dINetDate), 2) LOCAL cINetMonth := left(NtoCMonth(Month(dINetDate)), 3) LOCAL cINetYear := StrZero(Year(dINetDate), 4) LOCAL cINetTBias := GetTimeBias() LOCAL cINetTZone := GetTimeZone(cINetTBias) return (cINetDoW + ', ' + cINetDay + ' ' + cINetMonth + ' ' + cINetYear + ; ' ' + cINetTime + ' ' + cINetTBias + iif(empty(cINetTZone), '', ' (' + ; cINetTZone + ')')) Function GetTimeBias() LOCAL nMinutes := val(SetLocale(NLS_ITZBIAS)) LOCAL cHours := StrZero(int(abs(nMinutes) / 60), 2) LOCAL cMinutes := StrZero(abs(nMinutes) % 60, 2) return (iif(nMinutes < 0, '-', '+') + cHours + cMinutes) Function GetTimeZone(cINetTBias) *********************************************************************** * See RFC 733 and RFC 822 for details and possible values. SetLocale(NLS_STIMEZONE) returns a long text instead of a trigraph! * *********************************************************************** LOCAL lIsDST := val(SetLocale(NLS_ITZDAYLIGHTBIAS)) # 0 LOCAL cTimeZone := '' SetLocale(NLS_STIMEZONE) returns the full length text, and not a TriGraph! do case case cINetTBias == '+0200' if lIsDST cTimeZone := 'MDT' Middle-European Daylight-Savings Time endif case cINetTBias == '+0100' if lIsDST cTimeZone := 'GDT' Greenwich Daylight-Savings Time else cTimeZone := 'MET' Middle-European Time endif case cINetTBias == '-0300' if lIsDST cTimeZone := 'ADT' Atlantic Daylight-Savings Time endif case cINetTBias == '-0330' if lIsDST cTimeZone := 'NST' Newfoundland Standard Time endif case cINetTBias == '-0400' if lIsDST cTimeZone := 'EDT' Eastern Daylight-Savings Time else cTimeZone := 'AST' Atlantic Standard Time endif case cINetTBias == '-0500' if lIsDST cTimeZone := 'CDT' Central Daylight-Savings Time else cTimeZone := 'EST' Eastern Standard Time endif case cINetTBias == '-0600' if lIsDST cTimeZone := 'MDT' Mountain Daylight-Savings Time else cTimeZone := 'CST' Central Standard Time endif case cINetTBias == '-0700' if lIsDST cTimeZone := 'PDT' Pacific Daylight-Savings Time else cTimeZone := 'MST' Mountain Standard Time endif case cINetTBias == '-0800' if lIsDST cTimeZone := 'YDT' Yukon Daylight-Savings Time else cTimeZone := 'PST' Pacific Standard Time endif case cINetTBias == '-0900' if lIsDST cTimeZone := 'HDT' Hawaiian Daylight-Savings Time else cTimeZone := 'YST' Yukon Standard Time endif case cINetTBias == '-1000' if lIsDST cTimeZone := 'BDT' Bering Daylight-Savings Time else cTimeZone := 'HST' Hawaiian Standard Time endif case cINetTBias == '-1100' if lIsDST cTimeZone := 'BST' Bering Standard Time endif otherwise if val(cINetTBias) == 0 cTimeZone := 'GMT' Greenwich Mean Time (or UT/UTC - (Coordinated) Universal Time) endif endcase return (cTimeZone) Hope that helps, -- Andreas --- --- Andreas Gehrs-Pahl E-Mail: GPahl@CharterMI.net 415 Gute Street or: Andreas@DDPSoftware.com Owosso, MI 48867-4410 or: Andreas@Aerospace-History.net Tel: (989) 723-9927 Web Site: http://www.Aerospace-History.net --- --- | |
Frans Vermeulen | Re: MimeMessage DATE header on Fri, 07 Mar 2008 19:57:59 +0100 Hi Andreas, > >When I send emails using SmtpClient, > >my date: header field is sent corrupted ie.: > >it is sent as: > >"Date: Date: Thu, 6 Mar 2008 16:40:23 +0100" > >Note the double designator "Date: " > > Yes, the Date header has been broken for ever. Originally, ASINet > didn't set the date at all (PDR 5069) and now it apparently doesn't > do a very good job when setting it. Thanks for confirming my findings. > >Has anyone have the same experience, and is there a solution? > > I have written my own routine to set this header. I also received a Cool, I'm just home for the weekend, after a day at a sublocation, but if this does not do the job, nothing will, thanks again. Regards, Frans Vermeulen | |
Frans Vermeulen | Re: MimeMessage DATE header on Wed, 12 Mar 2008 12:16:02 +0100 Andreas, I set it live yesterday, and it works perfectly. Thnx, Frans Vermeulen > Frans, > > >When I send emails using SmtpClient, > >my date: header field is sent corrupted ie.: > >it is sent as: > >"Date: Date: Thu, 6 Mar 2008 16:40:23 +0100" > >Note the double designator "Date: " > > Yes, the Date header has been broken for ever. Originally, ASINet > didn't set the date at all (PDR 5069) and now it apparently doesn't > do a very good job when setting it. > > >Has anyone have the same experience, and is there a solution? > > I have written my own routine to set this header. I also received a > (wish list) PDR to allow the setting of this header in a user-friendly > way (PDR 5312), but so far nothing has materialized. > > > When I try to correct it > > oMimeMessage:GetHeader("DATE") returns NIL > > and > > oMimeMessage:SetHeader("DATE", Left(CDoW(Date()), 3)+; > > ", "+Var2Char(Day(Date()))+" "+Left(cMonth(Date()), 3)+" "+; > > Var2Char(Year(Date()))+" "+Time()+" +0100") > > does not seem to work. > > As there is no "Date:" header, I always Add one, doing the following: > > LOCAL oEMail := MIMEMessage():New() > [...] > oEMail:AddHeader("Date", INetDate(cDateTime)) > [...] > > Function INetDate(cDTStamp) > LOCAL dINetDate := iif(cDTStamp == NIL, Date(), StoD(left(cDTStamp, 8))) > LOCAL cINetTime := iif(cDTStamp == NIL, Time(), substr(cDTStamp, 9, 8)) > LOCAL cINetDate := DtoC(dINetDate) > LOCAL cINetDoW := left(NtoCDoW(DoW(dINetDate)), 3) > LOCAL cINetDay := StrZero(Day(dINetDate), 2) > LOCAL cINetMonth := left(NtoCMonth(Month(dINetDate)), 3) > LOCAL cINetYear := StrZero(Year(dINetDate), 4) > LOCAL cINetTBias := GetTimeBias() > LOCAL cINetTZone := GetTimeZone(cINetTBias) > return (cINetDoW + ', ' + cINetDay + ' ' + cINetMonth + ' ' + cINetYear + ; > ' ' + cINetTime + ' ' + cINetTBias + iif(empty(cINetTZone), '', ' (' + ; > cINetTZone + ')')) > > Function GetTimeBias() > LOCAL nMinutes := val(SetLocale(NLS_ITZBIAS)) > LOCAL cHours := StrZero(int(abs(nMinutes) / 60), 2) > LOCAL cMinutes := StrZero(abs(nMinutes) % 60, 2) > return (iif(nMinutes < 0, '-', '+') + cHours + cMinutes) > > Function GetTimeZone(cINetTBias) > *********************************************************************** > * See RFC 733 and RFC 822 for details and possible values. * > * SetLocale(NLS_STIMEZONE) returns a long text instead of a trigraph! * > *********************************************************************** > LOCAL lIsDST := val(SetLocale(NLS_ITZDAYLIGHTBIAS)) # 0 > LOCAL cTimeZone := '' SetLocale(NLS_STIMEZONE) returns the full > length text, and not a TriGraph! > do case > case cINetTBias == '+0200' > if lIsDST > cTimeZone := 'MDT' Middle-European Daylight-Savings Time > endif > case cINetTBias == '+0100' > if lIsDST > cTimeZone := 'GDT' Greenwich Daylight-Savings Time > else > cTimeZone := 'MET' Middle-European Time > endif > case cINetTBias == '-0300' > if lIsDST > cTimeZone := 'ADT' Atlantic Daylight-Savings Time > endif > case cINetTBias == '-0330' > if lIsDST > cTimeZone := 'NST' Newfoundland Standard Time > endif > case cINetTBias == '-0400' > if lIsDST > cTimeZone := 'EDT' Eastern Daylight-Savings Time > else > cTimeZone := 'AST' Atlantic Standard Time > endif > case cINetTBias == '-0500' > if lIsDST > cTimeZone := 'CDT' Central Daylight-Savings Time > else > cTimeZone := 'EST' Eastern Standard Time > endif > case cINetTBias == '-0600' > if lIsDST > cTimeZone := 'MDT' Mountain Daylight-Savings Time > else > cTimeZone := 'CST' Central Standard Time > endif > case cINetTBias == '-0700' > if lIsDST > cTimeZone := 'PDT' Pacific Daylight-Savings Time > else > cTimeZone := 'MST' Mountain Standard Time > endif > case cINetTBias == '-0800' > if lIsDST > cTimeZone := 'YDT' Yukon Daylight-Savings Time > else > cTimeZone := 'PST' Pacific Standard Time > endif > case cINetTBias == '-0900' > if lIsDST > cTimeZone := 'HDT' Hawaiian Daylight-Savings Time > else > cTimeZone := 'YST' Yukon Standard Time > endif > case cINetTBias == '-1000' > if lIsDST > cTimeZone := 'BDT' Bering Daylight-Savings Time > else > cTimeZone := 'HST' Hawaiian Standard Time > endif > case cINetTBias == '-1100' > if lIsDST > cTimeZone := 'BST' Bering Standard Time > endif > otherwise > if val(cINetTBias) == 0 > cTimeZone := 'GMT' Greenwich Mean Time (or UT/UTC - > (Coordinated) Universal Time) > endif > endcase > return (cTimeZone) > > Hope that helps, > > -- Andreas > > --- --- > Andreas Gehrs-Pahl E-Mail: GPahl@CharterMI.net > 415 Gute Street or: Andreas@DDPSoftware.com > Owosso, MI 48867-4410 or: Andreas@Aerospace-History.net > Tel: (989) 723-9927 Web Site: http://www.Aerospace-History.net > --- --- |