Article View: borland.public.cppbuilder.internet.web
Article #1466Re: I am using NMSMTP, how do I set up the "sent date".
From: Remy Lebeau (TeamB)
Date: Mon, 10 Jan 2005 18:25
Date: Mon, 10 Jan 2005 18:25
78 lines
3378 bytes
3378 bytes
"Steve Westwood" <S-Westwood@RCN.COM> wrote in message
news:41e288a7$1@newsgroups.borland.com...
> I thought it should have been:
> NMSMTP1->PostMessageA->Date = Now();
Date is a string, whereas Now() returns a TDateTime instead. E-mail dates
must be formatted in a special way. The default TDateTime-to-String
conversion does not use the proper format at all. You would have to convert
the TDateTime manually, ie:
AnsiString __fastcall GetGMTOffsetStr()
{
int iBias:
TIME_ZONE_INFORMATION tmez = {0};
switch( GetTimeZoneInformation(&tmez) )
{
case TIME_ZONE_ID_INVALID:
throw Exception();
break;
case TIME_ZONE_ID_UNKNOWN:
iBias = tmez.Bias;
break;
case TIME_ZONE_ID_DAYLIGHT:
iBias = (tmez.Bias + tmez.DaylightBias);
break;
case TIME_ZONE_ID_STANDARD:
iBias = (tmez.Bias + tmez.StandardBias);
break;
default:
throw Exception();
break;
}
TDateTime dt = EncodeTime(abs(iBias) / 60, abs(iBias) % 60, 0, 0);
if( iBias > 0 )
dt = (0 - dt);
WORD wHour, wMin, wSec, wMSec;
dt.DecodeTime(&wHour, &wMin, &wSec, &wMSec);
AnsiString Result = Format(" %0.2d%0.2d", ARRAYOFCONST(( wHour,
wMin )) );
if( OffsetFromUTC < 0.0 )
Result[1] = '-';
else
Result[1] = '+';
return Result;
}
AnsiString __fastcall DateTimeToInternetStr(const TDateTime &AValue)
{
static char* wdays[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
"Sat"};
static char* monthnames[12] = {"Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
WORD wYear, wMonth, wDay;
AValue.DecodeDate(&wYear, &wMonth, &wDay);
return Format("%s, %d %s %d %s %s",
ARRAYOFCONST(( wdays[AValue.DayOfWeek()-1], wDay,
monthnames[wMonth-1],
wYear, AValue.FormatString("HH:NN:SS"),
GetGMTOffsetStr() )) );
}
NMSMTP1->PostMessageA->Date = DateTimeToInternetStr(Now());
In any case, I would suggest not using TNMSMTP at all. The NetMasters
components are notoriously buggy and problematic in general.
Gambit
Technical Details
Message-ID:
<41e2c814$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41e288a7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,ecf8d057ce6c4cc5 X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.web References: <41e288a7$1@newsgroups.borland.com> Subject: Re: I am using NMSMTP, how do I set up the "sent date". Date: Mon, 10 Jan 2005 10:25:01 -0800 Lines: 80 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41e2c814$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1105381396 68.69.17.41 (10 Jan 2005 10:23:16 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail