四个问题,欢迎来看看(广告之后,马上回来)

ou630j 2009-01-07 02:32:56
1 idpop3正文的接收的解码?

我知道用IdDecoderMIME1可以解码,但问题是他只解前面一部份的,后面断开的就不解码了,然后我用消除空值,消除回车,消除换行还是解决不了

谁做过相关的解码工作,求教?

2如何把文件上传到指定的服务器文件夹,如果没有该文件夹就创建这个路径
求教高手(不能用copyfile)
也不能用idhttp,用idhttp就只能打开网址,可我的不是网址,只能靠一个IP加上路径,没有办法识别


3如何在把一个IP地址指向的文件夹的文件下载到本地,求教




4帮顶有分
...全文
178 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
magicjove 2009-01-14
  • 打赏
  • 举报
回复
UP,是个汉子!
代码跳动 2009-01-14
  • 打赏
  • 举报
回复
回答如此强悍,我怀疑你还是不是人
lcgboy 2009-01-14
  • 打赏
  • 举报
回复

function QuotedPrintableEncode(mSource: string): string;
var
I, J: Integer;
begin
Result := '';
J := 0;
for I := 1 to Length(mSource) do begin
if mSource[I] in [#32..#127, #13, #10] - ['='] then begin
Result := Result + mSource[I];
Inc(J);
end else begin
Result := Result + '=' + IntToHex(Ord(mSource[I]), 2);
Inc(J, 3);
end;
if mSource[I] in [#13, #10] then J := 0;
if J >= 70 then begin
Result := Result + #13#10;
J := 0;
end;
end;
end; { QuotedPrintableEncode }

function QuotedPrintableDecode(mCode: string): string;
var
I, J, L: Integer;
begin
Result := '';
J := 0;
mCode := AdjustLineBreaks(mCode);
L := Length(mCode);
I := 1;
while I <= L do begin
if mCode[I] = '=' then begin
Result := Result + Chr(StrToIntDef('$' + Copy(mCode, I + 1, 2), 0));
Inc(J, 3);
Inc(I, 3);
end else if mCode[I] in [#13, #10] then begin
if J < 70 then Result := Result + mCode[I];
if mCode[I] = #10 then J := 0;
Inc(I);
end else begin
Result := Result + mCode[I];
Inc(J);
Inc(I);
end;
end;
end; { QuotedPrintableDecode }

function Base64Encode(mSource: string; mAddLine: Boolean = True): string;
var
I, J: Integer;
S: string;
begin
Result := '';
J := 0;
for I := 0 to Length(mSource) div 3 - 1 do begin
S := Copy(mSource, I * 3 + 1, 3);
Result := Result + cBase64[Ord(S[1]) shr 2 + 1];
Result := Result + cBase64[((Ord(S[1]) and $03) shl 4) + (Ord(S[2]) shr 4) + 1];
Result := Result + cBase64[((Ord(S[2]) and $0F) shl 2) + (Ord(S[3]) shr 6) + 1];
Result := Result + cBase64[Ord(S[3]) and $3F + 1];
if mAddLine then begin
Inc(J, 4);
if J >= 76 then begin
Result := Result + #13#10;
J := 0;
end;
end;
end;
I := Length(mSource) div 3;
S := Copy(mSource, I * 3 + 1, 3);
case Length(S) of
1: begin
Result := Result + cBase64[Ord(S[1]) shr 2 + 1];
Result := Result + cBase64[(Ord(S[1]) and $03) shl 4 + 1];
Result := Result + cBase64[65];
Result := Result + cBase64[65];
end;
2: begin
Result := Result + cBase64[Ord(S[1]) shr 2 + 1];
Result := Result + cBase64[((Ord(S[1]) and $03) shl 4) + (Ord(S[2]) shr 4) + 1];
Result := Result + cBase64[(Ord(S[2]) and $0F) shl 2 + 1];
Result := Result + cBase64[65];
end;
end;
end; { Base64Encode }

function Base64Decode(mCode: string): string;
var
I, L: Integer;
S: string;
begin
Result := '';
L := Length(mCode);
I := 1;
while I <= L do begin
if Pos(mCode[I], cBase64) > 0 then begin
S := Copy(mCode, I, 4);
if (Length(S) = 4) then begin
Result := Result + Chr((Pos(S[1], cBase64) - 1) shl 2 +
(Pos(S[2], cBase64) - 1) shr 4);
if S[3] <> cBase64[65] then begin
Result := Result + Chr(((Pos(S[2], cBase64) - 1) and $0F) shl 4 +
(Pos(S[3], cBase64) - 1) shr 2);
if S[4] <> cBase64[65] then
Result := Result + Chr(((Pos(S[3], cBase64) - 1) and $03) shl 6 +
(Pos(S[4], cBase64) - 1));
end;
end;
Inc(I, 4);
end else Inc(I);
end;
end; { Base64Decode }

function GetMailTitle(const Value: string): string;
var
iPos: integer;
begin
Result := Value;
if Copy(Value, 1, 2) <> '=?' then
begin
Result := Value;
exit;
end;
//'?B?'前面的都要去掉
iPos := Pos('?B?', Value);
if iPos = 0 then
begin
iPos := Pos('?Q?', Value);
if iPos = 0 then
begin
Result := Value;
exit;
end;
Inc(iPos, 3);
//最后的'?='也要去掉
Result := Copy(Value, iPos, Length(Value) - iPos - 1);
Result := QuotedPrintableDecode(Result);
end
else
begin
Inc(iPos, 3);
//最后的'?='也要去掉
Result := Copy(Value, iPos, Length(Value) - iPos - 1);
Result := Base64Decode(Result);
end;
end;
//由于发件人是中文+'<mail@mailServer.com>',组成的,所以多加了这个函数!

function GetMailSender(const value: string): string;
var
iPos: integer;
preStr: string;
bkStr: string;
begin
Result := value;
if Copy(Value, 1, 2) <> '=?' then
begin
Result := Value;
exit;
end;
iPos := Pos('?= <', Value);
if iPos = 0 then
begin
Result := Value;
exit;
end
else
begin
preStr := Copy(Value, 1, iPos + 1);
bkStr := Copy(Value, iPos + 2, length(Value) - iPos + 2);
Result := GetMailTitle(preStr) + bkStr;
end;
end;
end.


2,3服务器开通ftp,用idftp上传下载。
4顶
lcgboy 2009-01-14
  • 打赏
  • 举报
回复
1,用一下代码解码:

unit MyMailBase64;

interface

uses
Windows, SysUtils, StrUtils, Classes;
function GetMailTitle(const Value: string): string;
function GetMailSender(const value: string): string;
function MailDeCode(const src: string): string;
function Base64Decode(mCode: string): string;
const
cBase64: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

implementation

procedure StrToStrList(sign: string; str: string; var StrList: TStringList);
var
temp: string;
begin
StrList.Text := '';
while Pos(sign, str) > 0 do
begin
temp := Copy(str, 1, Pos(sign, str) - 1);
Delete(str, 1, Pos(sign, str) + Length(sign) - 1);
StrList.Add(temp);
end;
if Length(str) > 0 then
StrList.Add(str);
end;

function MailDeCode(const src: string): string;
var
i, Pos1, pos2, pos3: Integer;
post: string;
srclist: Tstringlist;
function Decoder(const s: string): string;
var
s1, s2, s3: Integer;
t, v: string;
Encoding: Char;
hex, step: Integer;
a1: array[1..4] of Byte;
b1: array[1..4] of Byte;
j: Integer;
byte_ptr, real_bytes: Integer;
begin
s1 := Pos('=?', s);
s2 := 1;
hex := 0;
if s1 > 0 then
for s2 := Length(s) - 1 downto 1 do
if Copy(s, s2, 2) = '?=' then Break;
if (s1 = 0) or (s2 = 1) then
begin
Result := s;
Exit;
end;
t := Copy(s, s1 + 2, s2 - s1 - 2);
s3 := Pos('?', t);
Delete(t, 1, s3);
if t = '' then
begin
Result := s;
Exit;
end;
Encoding := t[1];
Delete(t, 1, 2);
v := '';
step := 0;
case Encoding of
'Q':
while t <> '' do
begin
case step of
0: begin
case t[1] of
'_': v := v + ' ';
'=': step := 1;
else
v := v + t[1];
end;
end;
1: begin
if t[1] <= '9' then hex := (Ord(t[1]) - ord('0')) * 16
else hex := (Ord(t[1]) - 55) * 16;
step := 2;
end;
2: begin
if t[1] <= '9' then hex := hex + (Ord(t[1]) - Ord('0'))
else hex := hex + Ord(t[1]) - 55;
step := 0;
end;
end;
Delete(t, 1, 1);
end;
'B': begin
byte_ptr := 0;
for j := 1 to Length(t) do
begin
Inc(byte_ptr);
case t[j] of
'A'..'Z': a1[byte_ptr] := Ord(t[j]) - 65;
'a'..'z': a1[byte_ptr] := Ord(t[j]) - 71;
'0'..'9': a1[byte_ptr] := Ord(t[j]) + 4;
'+': a1[byte_ptr] := 62;
'/': a1[byte_ptr] := 63;
'=': a1[byte_ptr] := 64;
end;
if byte_ptr = 4 then
begin
byte_ptr := 0;
real_bytes := 3;
if a1[1] = 64 then real_bytes := 0;
if a1[3] = 64 then begin
a1[3] := 0;
a1[4] := 0;
real_bytes := 1;
end;
if a1[4] = 64 then begin
a1[4] := 0;
real_bytes := 2;
end;
b1[1] := a1[1] * 4 + (a1[2] div 16);
b1[2] := (a1[2] mod 16) * 16 + (a1[3] div 4);
b1[3] := (a1[3] mod 4) * 64 + a1[4];
if real_bytes > 0 then
v := v + chr(b1[1]);
if real_bytes > 1 then
v := v + chr(b1[2]);
if real_bytes > 2 then
v := v + chr(b1[3]);
end;
end;
end;
end;
Result := Copy(s, 1, s1 - 1) + v + Copy(s, s2, Length(s));
if Pos('***SPAM***', Result) > 0 then
Result := Copy(Result, Pos('-', Result) + 1, Length(Result));
//Result := Copy(Result, Pos('-', Result) + 1, Length(Result) - pos('-', Result));
end;
begin
Pos1 := Pos('=?', src);
pos2 := 1;
if Pos1 > 0 then
for pos2 := Length(src) - 1 downto 1 do
if Copy(src, pos2, 2) = '?=' then Break;
if (Pos1 = 0) or (pos2 = 1) then begin
Result := src;
Exit;
end;
post := Copy(src, Pos1 + 2, pos2 - 2 - pos1);
pos3 := Pos('?', post);
Delete(post, 1, pos3);
if post = '' then
begin
Result := src;
Exit;
end;
srclist := TStringList.Create;
try
srclist.Clear;
StrToStrList(' ', src, srclist);
Result := '';
for i := 0 to srclist.Count - 1 do
begin
post := srclist.Strings[i];
Result := Result + Decoder(post);
end;
finally
srclist.Free;
end;
//去掉最后的'?='
if Pos('?=', Result) > 0 then
Delete(Result, Pos('?=', Result), 2);
end;

function QuotedPrintableEncode(mSource: string): string;
var
I, J: Integer;
begin
Result := '';
J := 0;
for I := 1 to Length(mSource) do begin
if mSource[I] in [#32..#127, #13, #10] - ['='] then begin
Result := Result + mSource[I];
Inc(J);
end else begin
Result := Result + '=' + IntToHex(Ord(mSource[I]), 2);
Inc(J, 3);
end;
if mSource[I] in [#13, #10] then J := 0;
if J >= 70 then begin
Result := Result + #13#10;
J := 0;
end;
end;
end; { QuotedPrintableEncode }



7年 2009-01-14
  • 打赏
  • 举报
回复
UP
mandarin 2009-01-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zqdue 的回复:]
1.帮顶
2.帮顶
3.帮顶
[/Quote]
帮顶
gwhdaxia 2009-01-14
  • 打赏
  • 举报
回复
UP
纯冰糖 2009-01-13
  • 打赏
  • 举报
回复
帮顶
faith10099 2009-01-13
  • 打赏
  • 举报
回复
有以为是广告帖呢
ou630j 2009-01-08
  • 打赏
  • 举报
回复
等待高手
kv2002 2009-01-07
  • 打赏
  • 举报
回复
友情助顶,等待高手
wsxcdx 2009-01-07
  • 打赏
  • 举报
回复
up
zqdue 2009-01-07
  • 打赏
  • 举报
回复
1.帮顶
2.帮顶
3.帮顶
starluck 2009-01-07
  • 打赏
  • 举报
回复
UP
Corn1 2009-01-07
  • 打赏
  • 举报
回复
1. 不知道
2. FTP?
3. Http.Get,最简单的方法
4. 帮顶...
de410 2009-01-07
  • 打赏
  • 举报
回复
帮顶一下~~

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧