stmp发送mime格式附件或文本都是字符
众神合一 2011-09-30 10:15:59 先谢谢大家,我弄了好几天,都不显示附件,接收到的都是文字.谁能帮帮我啊,
我对比了好几个网上代码,也没买找到问题
[code=C/C++]
memset(sendBuff,'\0',sizeof(sendBuff));
strcat(sendBuff,"FROM:xxxxx@163.com\r\n");
strcpy(sendBuff,"TO:xxxxx@qq.com\r\n");
strcpy(sendBuff,"Date: Tue, 27 Sep 2011 16:40:27 +0800\r\n");
strcat(sendBuff,"SUBJECT:Hello word from stmp \r\n\r\n");
send(sockClient,sendBuff,strlen(sendBuff),0);
memset(sendBuff,0x00,sizeof(sendBuff));
strcat(sendBuff,"MIME-Version:1.0\r\n");
strcat(sendBuff,"Content-Type:multipart/alternative;\r\n
boundary=\"----=_NextPart_000_0006_01CC7D34.2E304AF0\"\r\n");
strcat(sendBuff,"X-Priority: 3\r\n");
strcat(sendBuff,"X-MSMail-Priority: Normal\r\n");
strcat(sendBuff,"X-Unsent: 1\r\n");
strcat(sendBuff,"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109\r\n\r\n");
strcat(sendBuff,"This is a simple mail.\r\n\r\n");
send(sockClient,sendBuff,strlen(sendBuff),0);
memset(sendBuff,0x00,sizeof(sendBuff));
strcat(sendBuff,"------=_NextPart_000_0006_01CC7D34.2E304AF0\r\n");
strcat(sendBuff,"Content-Type: text/plain;\r\n charset=\"gb2312\"\r\n");
strcat(sendBuff,"Content-Transfer-Encoding: base64\r\n\r\n");
strcat(sendBuff,"0ru49rfJu/rNvMas\r\n\r\n");
send(sockClient,sendBuff,strlen(sendBuff),0);
memset(sendBuff,0x00,sizeof(sendBuff));
strcat(sendBuff,"------=_NextPart_000_0006_01CC7D34.2E304AF0\r\n");
strcat(sendBuff,"Content-Type: text/html;\r\n charset=\"gb2312\"\r\n");
strcat(sendBuff,"Content-Transfer-Encoding: base64\r\n\r\n");
strcat(sendBuff,"base64\r\n");
strcat(sendBuff,"base64\r\n\r\n");
strcat(sendBuff,"------=_NextPart_000_0006_01CC7D34.2E304AF0--\r\n\r\n");
send(sockClient,sendBuff,strlen(sendBuff),0);
memset(sendBuff,'\0',MAXLEN);
strcat(sendBuff,"\r\n.\r\n");
send(sockClient,sendBuff,strlen(sendBuff),0);
[code]
outlook的eml文件
From: "afd" <xxx@163.com>
To: "xxxx@qq.com"
Subject: =?gb2312?B?xOO6wyzV4rj2ysey4srU08q8/g==?=
Date: Tue, 27 Sep 2011 16:40:27 +0800
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0006_01CC7D34.2E304AF0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Unsent: 1
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109
This is a multi-part message in MIME format.
------=_NextPart_000_0006_01CC7D34.2E304AF0
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: base64
0ru49rfJu/rNvMas
------=_NextPart_000_0006_01CC7D34.2E304AF0
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: base64
base64
------=_NextPart_000_0006_01CC7D34.2E304AF0--