Hi John,
Finally ran the thing in debug and looked at the Date header. It currently
looks like this:
Date: Wed Nov 5 15:12:16 2008
There's more wrong with this than the missing time zone! Again, RFC
2822 is VERY SPECIFIC about the format of the timestamp. If you don't
believe me, look at section 3.3 of the docs, here:
http://www.faqs.org/rfcs/rfc2822.html
It must be in this format:
Date: [DayOfWeek,] Day Month Year Hour:Minute:Second TimeZone
a) The day of the week is optional, but if included, it must be followed
by a comma. Yours lacks that comma.
b) The day number must precede the month. Your example has it after the
month.
c) The year comes after the month. Your example has the year after the
time of day.
d) And, of course, yours is missing the time zone.
Even though Microsoft Outlook may be smart enough to figure out at least
part of the date you've supplied, not every e-mail program will be.
Indeed, I'd suggest that many programmers wouldn't write complex
routines designed to handle many possible date formats because, after,
all, the standards give the exact date format that you're supposed to use.
Plus, even if everyone you know and love uses Microsoft Outlook, there's
still SMTP, IMAP and POP servers that doubtless will have to relay the
email from your computer to whomever is running Outlook. That software
won't understand the date format either.
Anyway... if you like, here's the routine I use to calculate the date.
Ultimately, this data comes from the QDATE, QTIME and QUTCOFFSET/QTIMZON
sysvals, but I use the ILE date/time routines which makes it easier to
put in the format I want. Hopefully, it's useful to you (or someone else)
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* SMTP_getTime(): Get the current date/time from the
* system clock, formatting in SMTP fashion
*
* For example: 'Mon, 15 Aug 2006 14:30:06 -0500'
*
* returns the date/time string.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P SMTP_getTime B export
D SMTP_getTime PI 31A
D CEELOCT PR opdesc
D Lilian 10I 0
D Seconds 8F
D Gregorian 23A
D fc 12A options(*omit)
D CEEUTCO PR opdesc
D Hours 10I 0
D Minutes 10I 0
D Seconds 8F
D fc 12A options(*omit)
D CEEDATM PR opdesc
D input_secs 8F const
D date_format 80A const options(*varsize)
D char_date 80A options(*varsize)
D feedback 12A options(*omit)
D rfc2822 c 'Www, DD Mmm YYYY HH:MI:SS'
D junk1 s 8F
D junk2 s 10I 0
D junk3 s 23A
D hours s 10I 0
D mins s 10I 0
D tz_hours s 2P 0
D tz_mins s 2P 0
D tz s 5A varying
D CurTime s 8F
D Temp s 25A
/free
//
// Calculate the Timezone in format '+0000', for example
// CST should show up as '-0600'
//
CEEUTCO(hours: mins: junk1: *omit);
tz_hours = %abs(hours);
tz_mins = mins;
if (hours < 0);
tz = '-';
else;
tz = '+';
endif;
tz += %editc(tz_hours:'X') + %editc(tz_mins:'X');
//
// Get the current time and convert it to the format
// specified for e-mail in RFC 2822
//
CEELOCT(junk2: CurTime: junk3: *omit);
CEEDATM(CurTime: rfc2822: Temp: *omit);
return Temp + ' ' + tz;
/end-free
P E
As an Amazon Associate we earn from qualifying purchases.