Delphi 6 中我使用
//=================================
procedure SendMailWithAttachments(Recipients : String;Subject:String; NoteText:TStrings; Attachments : TStrings);
type
TSZBuf = array[0..255] of char;
var
RC : ULONG;
Recip : TMapiRecipDesc;
Mail : TMapiMessage;
pAttachments : array of TMapiFileDesc;
i, AttachmentCount : Integer;
begin
with Recip do
begin
ulReserved := 0;
ulRecipClass := MAPI_TO;
lpszName := nil;
lpszAddress := pchar(Recipients);
ulEIDSize := 0;
lpEntryID := nil;
end; if (Attachments = nil) or (Attachments.Count = 0) then
begin
AttachmentCount := 0;
pAttachments := nil;
end
else
begin
AttachmentCount := Attachments.Count;
SetLength(pAttachments, AttachmentCount);
for i := 0 to AttachmentCount - 1 do
with pAttachments[i] do
begin
ulReserved := 0;
flFlags := 0;
nPosition := Cardinal(-1);
lpszPathName := AllocMem(sizeof(TSZBuf));
StrPcopy(lpszPathName, Attachments[i]);
lpszFileName := AllocMem(sizeof(TSZBuf));
StrPcopy(lpszFileName, ExtractFileName(Attachments[i]));
lpFileType := nil;
end;
end; with Mail do
begin
ulReserved := 0;
lpszSubject := Pchar(Subject);
if NoteText <> nil then
lpszNoteText := Pchar(NoteText.Text)
else
lpszNoteText := nil; lpszMessageType := nil;
// lpszMessageType := 'Text/HTML';
lpszDateReceived := nil;
lpszConversationID := nil;
flFlags := 0;
lpOriginator := nil;
if Recipients = '' then nRecipCount := 0
else nRecipCount := 1;
lpRecips := @Recip;
nFileCount := AttachmentCount;
lpFiles := Pointer(pAttachments);
end; try
RC := MapiSendMail(0, Application.Handle, Mail, MAPI_DIALOG +MAPI_LOGON_UI, 0);
if RC <> SUCCESS_SUCCESS then
ShowSendMailErr(RC);
finally
if AttachmentCount > 0 then
for i := 0 to AttachmentCount - 1 do
begin
FreeMem(pAttachments[i].lpszPathName);
FreeMem(pAttachments[i].lpszFileName);
end;
SetLength(pAttachments, 0);
end;
end;
//=================================
我这样调用上边的过程
.....
IdMessage.Body.LoadFromFile('E:\zt.htm');
IdMessage.Encoding:=meMIME;
IdMessage.ContentType:='Text/HTML';// //multipart/mixed
IdMessage.ContentTransferEncoding:='Base64';
IdMessage.SaveToFile('d:\ddd.eml',false);
IdMessage.Body.LoadFromFile('d:\ddd.eml');
.....
SendMailWithAttachments(EMailAddress,Subject,IdMessage.Body,AttachmentFiles);
结果调出outlook express看到的邮件的内容是编好码的邮件内容,如下:Content-Type: Text/HTML
MIME-Version: 1.0
Content-Transfer-Encoding: Base64
Date: Wed, 3 Aug 2005 13:31:15 +0800PGh0bWw+DQoNCjxoZWFkPg0KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1MYW5ndWFnZSIgY29u
dGVudD0iemgtY24iPg0KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0
ZXh0L2h0bWw7IGNoYXJzZXQ9Z2IyMzEyIj4NCjxtZXRhIG5hbWU9IkdFTkVSQVRPUiIgY29udGVu
dD0iTWljcm9zb2Z0IEZyb250UGFnZSA0LjAiPg0KPG1ldGEgbmFtZT0iUHJvZ0lkIiBjb250ZW50
PSJGcm9udFBhZ2UuRWRpdG9yLkRvY3VtZW50Ij4NCjx0aXRsZT5NYWd0ZWNossmx4M+1zbPNvLHq
.....
.....
L3RyPg0KICA8dHI+DQogICAgPHRkIHdpZHRoPSIxMDAlIiBhbGlnbj0icmlnaHQiIGNvbHNwYW49
IjIiIGhlaWdodD0iMjciPjxmb250IHNpemU9IjIiPjxhIGhyZWY9Imh0dHA6Ly93d3cubWFndGVj
aC5jb20uY24iPr60x+u52NeisbG+qcLquPHMqb/Lv8a8vLei1bnT0M/euavLvtfu0MKy+sa3us28
vMr1PC9hPjwvZm9udD48L3RkPg0KICA8L3RyPg0KPC90YWJsZT4NCg0KPC9ib2R5Pg0KDQo8L2h0
bWw+DQo=
.
但是把上边的内容保存为一个邮件比如aaa.eml用outlook express打开是正常的html格式的邮件
请问怎样才能使调出的outlook express生成的邮件能正常地显示为html邮件?
//=================================
procedure SendMailWithAttachments(Recipients : String;Subject:String; NoteText:TStrings; Attachments : TStrings);
type
TSZBuf = array[0..255] of char;
var
RC : ULONG;
Recip : TMapiRecipDesc;
Mail : TMapiMessage;
pAttachments : array of TMapiFileDesc;
i, AttachmentCount : Integer;
begin
with Recip do
begin
ulReserved := 0;
ulRecipClass := MAPI_TO;
lpszName := nil;
lpszAddress := pchar(Recipients);
ulEIDSize := 0;
lpEntryID := nil;
end; if (Attachments = nil) or (Attachments.Count = 0) then
begin
AttachmentCount := 0;
pAttachments := nil;
end
else
begin
AttachmentCount := Attachments.Count;
SetLength(pAttachments, AttachmentCount);
for i := 0 to AttachmentCount - 1 do
with pAttachments[i] do
begin
ulReserved := 0;
flFlags := 0;
nPosition := Cardinal(-1);
lpszPathName := AllocMem(sizeof(TSZBuf));
StrPcopy(lpszPathName, Attachments[i]);
lpszFileName := AllocMem(sizeof(TSZBuf));
StrPcopy(lpszFileName, ExtractFileName(Attachments[i]));
lpFileType := nil;
end;
end; with Mail do
begin
ulReserved := 0;
lpszSubject := Pchar(Subject);
if NoteText <> nil then
lpszNoteText := Pchar(NoteText.Text)
else
lpszNoteText := nil; lpszMessageType := nil;
// lpszMessageType := 'Text/HTML';
lpszDateReceived := nil;
lpszConversationID := nil;
flFlags := 0;
lpOriginator := nil;
if Recipients = '' then nRecipCount := 0
else nRecipCount := 1;
lpRecips := @Recip;
nFileCount := AttachmentCount;
lpFiles := Pointer(pAttachments);
end; try
RC := MapiSendMail(0, Application.Handle, Mail, MAPI_DIALOG +MAPI_LOGON_UI, 0);
if RC <> SUCCESS_SUCCESS then
ShowSendMailErr(RC);
finally
if AttachmentCount > 0 then
for i := 0 to AttachmentCount - 1 do
begin
FreeMem(pAttachments[i].lpszPathName);
FreeMem(pAttachments[i].lpszFileName);
end;
SetLength(pAttachments, 0);
end;
end;
//=================================
我这样调用上边的过程
.....
IdMessage.Body.LoadFromFile('E:\zt.htm');
IdMessage.Encoding:=meMIME;
IdMessage.ContentType:='Text/HTML';// //multipart/mixed
IdMessage.ContentTransferEncoding:='Base64';
IdMessage.SaveToFile('d:\ddd.eml',false);
IdMessage.Body.LoadFromFile('d:\ddd.eml');
.....
SendMailWithAttachments(EMailAddress,Subject,IdMessage.Body,AttachmentFiles);
结果调出outlook express看到的邮件的内容是编好码的邮件内容,如下:Content-Type: Text/HTML
MIME-Version: 1.0
Content-Transfer-Encoding: Base64
Date: Wed, 3 Aug 2005 13:31:15 +0800PGh0bWw+DQoNCjxoZWFkPg0KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1MYW5ndWFnZSIgY29u
dGVudD0iemgtY24iPg0KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0
ZXh0L2h0bWw7IGNoYXJzZXQ9Z2IyMzEyIj4NCjxtZXRhIG5hbWU9IkdFTkVSQVRPUiIgY29udGVu
dD0iTWljcm9zb2Z0IEZyb250UGFnZSA0LjAiPg0KPG1ldGEgbmFtZT0iUHJvZ0lkIiBjb250ZW50
PSJGcm9udFBhZ2UuRWRpdG9yLkRvY3VtZW50Ij4NCjx0aXRsZT5NYWd0ZWNossmx4M+1zbPNvLHq
.....
.....
L3RyPg0KICA8dHI+DQogICAgPHRkIHdpZHRoPSIxMDAlIiBhbGlnbj0icmlnaHQiIGNvbHNwYW49
IjIiIGhlaWdodD0iMjciPjxmb250IHNpemU9IjIiPjxhIGhyZWY9Imh0dHA6Ly93d3cubWFndGVj
aC5jb20uY24iPr60x+u52NeisbG+qcLquPHMqb/Lv8a8vLei1bnT0M/euavLvtfu0MKy+sa3us28
vMr1PC9hPjwvZm9udD48L3RkPg0KICA8L3RyPg0KPC90YWJsZT4NCg0KPC9ib2R5Pg0KDQo8L2h0
bWw+DQo=
.
但是把上边的内容保存为一个邮件比如aaa.eml用outlook express打开是正常的html格式的邮件
请问怎样才能使调出的outlook express生成的邮件能正常地显示为html邮件?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货