idpop3收信件问题,高手请进!!在线等待,马上给分!! 1.邮件标题中有汉字,收下来是乱码,如何解决?2.如何得到邮件大小,制作进度条? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.收下来得是乱码是因为字符串都经过了base64编码或者utf8编码base64编码解码得程序function Base64ToString(const Value : string): string;var x, y, n, l: Integer; d: array[0..3] of Byte; Table : string;begin Table := #$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$3E +#$40 +#$40 +#$40 +#$3F +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C +#$3D +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$01 +#$02 +#$03 +#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F +#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21 +#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D +#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40; SetLength(Result, Length(Value)); x := 1; l := 1; while x < Length(Value) do begin for n := 0 to 3 do begin if x > Length(Value) then d[n] := 64 else begin y := Ord(Value[x]); if (y < 33) or (y > 127) then d[n] := 64 else d[n] := Ord(Table[y - 32]); end; Inc(x); end; Result[l] := Char((D[0] and $3F) shl 2 + (D[1] and $30) shr 4); Inc(l); if d[2] <> 64 then begin Result[l] := Char((D[1] and $0F) shl 4 + (D[2] and $3C) shr 2); Inc(l); if d[3] <> 64 then begin Result[l] := Char((D[2] and $03) shl 6 + (D[3] and $3F)); Inc(l); end; end; end; Dec(l); SetLength(Result, l);end;function StringToBase64(const Value: string): string;var c: Byte; n, l: Integer; Count: Integer; DOut: array[0..3] of Byte; Table : string;begin Table := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; setlength(Result, ((Length(Value) + 2) div 3) * 4); l := 1; Count := 1; while Count <= Length(Value) do begin c := Ord(Value[Count]); Inc(Count); DOut[0] := (c and $FC) shr 2; DOut[1] := (c and $03) shl 4; if Count <= Length(Value) then begin c := Ord(Value[Count]); Inc(Count); DOut[1] := DOut[1] + (c and $F0) shr 4; DOut[2] := (c and $0F) shl 2; if Count <= Length(Value) then begin c := Ord(Value[Count]); Inc(Count); DOut[2] := DOut[2] + (c and $C0) shr 6; DOut[3] := (c and $3F); end else begin DOut[3] := $40; end; end else begin DOut[2] := $40; DOut[3] := $40; end; for n := 0 to 3 do begin Result[l] := Table[DOut[n] + 1]; Inc(l); end; end;end;function GetTitle(const Value: string): string;var iPos: integer;begin Result := Value; if Copy(Value, 1, 2) <> '=?' then exit; //'?B?'Ç°ÃæµÄ¶¼ÒªÈ¥µô iPos := Pos('?B?', Value); Inc(iPos, 3); //×îºóµÄ'?='ҲҪȥµô Result := Copy(Value, iPos, Length(Value) - iPos - 1); Result := Base64ToString(Result); //Result := Utf8ToAnsi(Result);end;2.你可以参看indy带的例子,它上面可以得到邮件的大小 indy例子中也没找到的到信件大小,恳请提示! 信件大小: int MailSize = idPOP->RetrieveMsgSize(i); 中文编码部分,不妨参考本人的BCB解决方案。http://expert.csdn.net/Expert/TopicView2.asp?id=1126270 邮件大小必须收取信件以后才知道,如果收取不到信件那么就无法得到大小如果想要知道信件大小只有自己写代码了,不用Idpop3控件 to 绝望的生鱼片:用你的代码还是没搞定,好像不是base64编码,是mime编码。to 空心菜:能不能帮我转换成delphi的语言,谢谢! Delphi我从来没有用过,不会转换,其实原理很简单,主要的Base64和Mine,Q_P解码部分的代码应该有delphi版本,你把我写的两个函数转换一下成Delphi就可以。 又:关于信件大小: int MailSize = idPOP->RetrieveMsgSize(i);用上面的代码收到的不是邮件的大小吗?我用的是Indy9。 图元文件显示 关于String转换为char的问题 f1book1预览 简单问题、简单问题、简单问题、简单问题。 如何将文件里的每一行内容存到一个数组里?谢谢各位大虾!!(初学者) 在开发VCL时。我想在VCL中,调用使用VCL时,输入的代码可以吗?如何实现?谢谢。 请教关于类型转换的问题 Delphi5的Code Insight的问题?例如我键入Query1.Ope时,弹出的下拉框不是Open 关于窗口融合问题? 哪里有类似outlook的对delphi5适用的控件? 小女子初学delphi,有一个小问题,请各位大哥帮忙!在线等待 如何实现用应用程序往网页里写入数据并提交?
base64编码解码得程序
function Base64ToString(const Value : string): string;
var
x, y, n, l: Integer;
d: array[0..3] of Byte;
Table : string;
begin
Table :=
#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$3E +#$40
+#$40 +#$40 +#$3F +#$34 +#$35 +#$36 +#$37 +#$38 +#$39 +#$3A +#$3B +#$3C
+#$3D +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40 +#$00 +#$01 +#$02 +#$03
+#$04 +#$05 +#$06 +#$07 +#$08 +#$09 +#$0A +#$0B +#$0C +#$0D +#$0E +#$0F
+#$10 +#$11 +#$12 +#$13 +#$14 +#$15 +#$16 +#$17 +#$18 +#$19 +#$40 +#$40
+#$40 +#$40 +#$40 +#$40 +#$1A +#$1B +#$1C +#$1D +#$1E +#$1F +#$20 +#$21
+#$22 +#$23 +#$24 +#$25 +#$26 +#$27 +#$28 +#$29 +#$2A +#$2B +#$2C +#$2D
+#$2E +#$2F +#$30 +#$31 +#$32 +#$33 +#$40 +#$40 +#$40 +#$40 +#$40 +#$40; SetLength(Result, Length(Value));
x := 1;
l := 1;
while x < Length(Value) do
begin
for n := 0 to 3 do
begin
if x > Length(Value) then
d[n] := 64
else
begin
y := Ord(Value[x]);
if (y < 33) or (y > 127) then
d[n] := 64
else
d[n] := Ord(Table[y - 32]);
end;
Inc(x);
end;
Result[l] := Char((D[0] and $3F) shl 2 + (D[1] and $30) shr 4);
Inc(l);
if d[2] <> 64 then
begin
Result[l] := Char((D[1] and $0F) shl 4 + (D[2] and $3C) shr 2);
Inc(l);
if d[3] <> 64 then
begin
Result[l] := Char((D[2] and $03) shl 6 + (D[3] and $3F));
Inc(l);
end;
end;
end;
Dec(l);
SetLength(Result, l);
end;function StringToBase64(const Value: string): string;
var
c: Byte;
n, l: Integer;
Count: Integer;
DOut: array[0..3] of Byte;
Table : string;
begin
Table :=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; setlength(Result, ((Length(Value) + 2) div 3) * 4);
l := 1;
Count := 1;
while Count <= Length(Value) do
begin
c := Ord(Value[Count]);
Inc(Count);
DOut[0] := (c and $FC) shr 2;
DOut[1] := (c and $03) shl 4;
if Count <= Length(Value) then
begin
c := Ord(Value[Count]);
Inc(Count);
DOut[1] := DOut[1] + (c and $F0) shr 4;
DOut[2] := (c and $0F) shl 2;
if Count <= Length(Value) then
begin
c := Ord(Value[Count]);
Inc(Count);
DOut[2] := DOut[2] + (c and $C0) shr 6;
DOut[3] := (c and $3F);
end
else
begin
DOut[3] := $40;
end;
end
else
begin
DOut[2] := $40;
DOut[3] := $40;
end;
for n := 0 to 3 do
begin
Result[l] := Table[DOut[n] + 1];
Inc(l);
end;
end;
end;function GetTitle(const Value: string): string;
var
iPos: integer;
begin
Result := Value;
if Copy(Value, 1, 2) <> '=?' then exit;
//'?B?'Ç°ÃæµÄ¶¼ÒªÈ¥µô
iPos := Pos('?B?', Value);
Inc(iPos, 3);
//×îºóµÄ'?='ҲҪȥµô
Result := Copy(Value, iPos, Length(Value) - iPos - 1);
Result := Base64ToString(Result);
//Result := Utf8ToAnsi(Result);
end;
2.你可以参看indy带的例子,它上面可以得到邮件的大小
int MailSize = idPOP->RetrieveMsgSize(i);
http://expert.csdn.net/Expert/TopicView2.asp?id=1126270
to 空心菜:能不能帮我转换成delphi的语言,谢谢!
int MailSize = idPOP->RetrieveMsgSize(i);
用上面的代码收到的不是邮件的大小吗?
我用的是Indy9。