关于用WinSock发带附件邮件的问题(200分)

  • 主题发起人 主题发起人 Ping2002
  • 开始时间 开始时间
P

Ping2002

Unregistered / Unconfirmed
GUEST, unregistred user!
我用WinSock发送一个带附件的邮件,操作成功。但是在邮件服务器端只能出现邮件体,而邮件正文以及附件都不可见。通过监控outlook express发送的包,与我所写程序发的内容基本是一致的。且在服务器端检查邮件原文,内容也基本一致。请问该情况如何出现的?
附我发送的邮件原文如下:
Received: from 21cn.com([59.36.102.14]) by 21cn.com(AIMC 3.1.0.0)
with SMTP id jm31d4518bf24; Tue, 26 Sep 2006 10:36:08 +0800
Received: from m12-16.163.com (unknown [202.105.45.9])
by 21cn.com (HERMES) with SMTP
for <zpgroup@21cn.com>; Tue, 26 Sep 2006 10:38:24 +0800 (CST)
Received: from m12-16.163.com([220.181.12.16]) by 21cn.com(AIMC 3.2.0.0)
with SMTP id AISP action; Tue, 26 Sep 2006 10:30:28 +0800
Received: from Ping (unknown [219.133.247.232])
by smtp9 (Coremail) with SMTP id wKjAEBMA2ARskRhFF0DNBA==.60467S2;
Tue, 26 Sep 2006 10:33:17 +0800 (CST)
Message-ID: <000d01c6e097$ea1a1820$6401a8c0@ping>
From: &quot;Ping&quot; <zpgroup@163.com>
To: <zpgroup@21cn.com>
Subject: 邮件测试
Date: Tue, 26 Sep 2006 10:33:01 +0800
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=&quot;----=_NextPart_000_000B_E055A9C9.2B8878F2&quot;
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailler: MailDemo
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-AIMC-AUTH: (null)
X-AIMC-MAILFROM: zpgroup@163.com
X-AIMC-Msg-ID: AConC2QB

This is a multi-part message in MIME format.

------=_NextPart_000_000B_234FCAD6.E3DDD233
Content-Type: text/plain;
charset=&quot;gb2312&quot;
Content-Transfer-Encoding: base64

tPi4vbz+08q8/g0K

------=_NextPart_000_000B_234FCAD6.E3DDD233
Content-Type: image/bmp;
name=&quot;Exit.bmp&quot;
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=&quot;Exit.bmp&quot;

Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAIAAAADEDgAAxA4AAAAAAAAAAAAAAAAA
AAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA
////AHd3d3d3+Hj4d3d3d3d/f3dERAB3f/9ERAAExAB//0AAAARMQP//QAAABMTA//9AAAAETED+
/kAAAATEwO/vQAAABExA/v5AAAAExMDv70AAAAREREREQAAAAAAAAAAAAAAAAAAAAAAAAAAAIiIA
AAAAAAAAAAAAAAAAAAAAAAAA

------=_NextPart_000_000B_234FCAD6.E3DDD233--
 
发送代码如下:
SendDemoCommand('EHLO Ping' + CRLF);

SendDemoCommand('AUTH LOGIN' + CRLF);
SendDemoCommand(EncodeBase64('******') + CRLF);
SendDemoCommand(EncodeBase64('******') + CRLF);
SendDemoCommand('MAIL FROM:<******@163.com>' + CRLF);
SendDemoCommand('RCPT TO:<******@21cn.com>' + CRLF);
SendDemoCommand('DATA' + CRLF);

SendDemoData(GetMailMessage);

SendDemoCommand('QUIT' + CRLF);

function TForm1.GetMailMessage: TStrings;
var
tmpBoundary, FileName: string;
Body: TStrings;
AttchFile: TMemoryStream;
begin
Result := TStringList.Create;
Body := TStringList.Create;
Body.Text := '带附件邮件';
FileName := 'F:/temp/Exit.bmp';
AttchFile := TMemoryStream.Create;
AttchFile.LoadFromFile(FileName);

tmpBoundary := GenarateBoundary('ShenZhen_XinF');

//头信息
Result.Add('Message-ID: <000d01c6e097$ea1a1820$6401a8c0@ping>');
Result.Add('From: &quot;Ping&quot; <zpgroup@163.com>');
Result.Add('To: <zpgroup@21cn.com>');
Result.Add('Subject: 邮件测试');
Result.Add('Date: ' + GetStandardMailDateTime);
Result.Add('MIME-Version: 1.0');
Result.Add(GetMimeHeader(mctMultiMixed));
Result.Add('X-Priority: 3');
Result.Add('X-MSMail-Priority: Normal');
Result.Add('X-Mailler: MailDemo');
Result.Add('X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180');
Result.Add('');
Result.Add('This is a multi-part message in MIME format.');
Result.Add('');

Result.Add('--' + tmpBoundary);
Result.Add('Content-Type: text/plain;');
Result.Add(#9+ 'charset=&quot;gb2312&quot;');
Result.Add('Content-Transfer-Encoding: base64');
Result.Add('');

Result.Add(BodyEncode(Body.Text));

Result.Add('');

Result.Add('--' + tmpBoundary);
Result.Add('Content-Type: ' + GetMimeType(FileName) + ';');
Result.Add(#9 + 'name=&quot;' + ExtractFileName(FileName) + '&quot;');
Result.Add('Content-Transfer-Encoding: base64');
Result.Add('Content-Disposition: attachment;');
Result.Add(#9 + 'filename=&quot;' + ExtractFileName(FileName) + '&quot;');
Result.Add('');
Result.Add(AttachEncode(AttchFile));

Result.Add('');
Result.Add('--' + tmpBoundary + '--');

Result.Add('');
Result.Add('.');

Result.SaveToFile('F:/temp/content.txt');
Body.Free;
AttchFile.Free;
end;
 
问题依旧,自己提前。
望做过邮件客户端的朋友给予支持,谢!
 
呵呵 学习 发邮件都这样麻烦 收邮件更麻烦S你
 
出于无奈,如果是纯软件问题好办,随便弄个控件就OK了。
但我写这个代码的目的是为了将该协议过程移植到嵌入式设备上,所以这些麻烦也是必须的。
 
注意你的内容:
Content-Type: multipart/mixed;
boundary=&quot;----=_NextPart_000_000B_E055A9C9.2B8878F2&quot;

------=_NextPart_000_000B_234FCAD6.E3DDD233
则两个地方标注的信息不是一个吧。

我看了一下有附件的,都是有对应关系的。
 
xiammy同学火眼金睛,一下就看到问题.
目前在外地出差,只有回去后测试,估计不会错了.多谢回复.
实在感到惭愧,如此明显的问题居然没有注意,失败.
 
国庆期间放假,耽误了xiammy同学的分分。现在补上。
 
接受答案了.
 
呵呵,能解决问题就好
 
后退
顶部