Thread View: borland.public.cppbuilder.internet.web
5 messages
5 total messages
Started by Steve Westwood
Mon, 10 Jan 2005 13:52
I am using NMSMTP, how do I set up the "sent date".
Author: Steve Westwood
Date: Mon, 10 Jan 2005 13:52
Date: Mon, 10 Jan 2005 13:52
12 lines
1119 bytes
1119 bytes
I am using NMSMTP, how do I set up the "sent date". I thought it should have been: NMSMTP1->PostMessageA->Date = Now(); This still leaves the sent date empty in the peoples inbox. Thank you, Steve
Re: I am using NMSMTP, how do I set up the "sent date".
Author: 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
Re: I am using NMSMTP, how do I set up the "sent date".
Author: Steve Westwood
Date: Wed, 12 Jan 2005 21:06
Date: Wed, 12 Jan 2005 21:06
88 lines
3883 bytes
3883 bytes
Thank you. But what is OffsetFromUTC
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:41e2c814$1@newsgroups.borland.com...
>
> "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
>
>
Re: I am using NMSMTP, how do I set up the "sent date".
Author: Remy Lebeau (TeamB)
Date: Wed, 12 Jan 2005 21:45
Date: Wed, 12 Jan 2005 21:45
15 lines
1316 bytes
1316 bytes
"Steve Westwood" <S-Westwood@RCN.COM> wrote in message
news:41e59169@newsgroups.borland.com...
> Thank you. But what is OffsetFromUTC
That was a typo on my part. It should have been "dt" instead:
if( dt < 0.0 )
Result[1] = '-';
else
Result[1] = '+';
Gambit
Re: I am using NMSMTP, how do I set up the "sent date".
Author: Mark Jacobs
Date: Tue, 18 Jan 2005 11:12
Date: Tue, 18 Jan 2005 11:12
11 lines
1494 bytes
1494 bytes
Steve Westwood wrote:
> I am using NMSMTP, how do I set up the "sent date". I thought it should
> have been:
> NMSMTP1->PostMessageA->Date = Now();
> This still leaves the sent date empty in the peoples inbox.
NMSMTP1->PostMessage->Date=Now().FormatString("ddd, d mmm yyyy hh:nn:ss -0000");
works for me in the UK.
MJ
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads