- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到以下问题。我创建了一个 Windows 服务,用于发送带有 .xls
附件的电子邮件。如果我使用 Windows Live Mail 或 Web Mail 打开电子邮件,它就可以工作,我可以看到附件。当我尝试使用 Microsoft Outlook 2010 打开电子邮件时,会出现问题,附件不存在,而且我不知道我的代码出了什么问题。
电子邮件标题如下所示
Return-Path: <no-reply@asdf.ro>
Delivered-To: sebi.ciuca@asdf.ro
Received: (qmail 25352 invoked by uid 500); 15 Jul 2015 14:58:23 -0000
Received: by simscan 1.4.0 ppid: 25345, pid: 25349, t: 0.0443s
scanners: attach: 1.4.0 clamav: 0.98.5/m:
Received: from unknown (HELO ab-c11) (task.test@asdf.ro@111.111.111.111)
by mail.absoft.ro with ESMTPA; 15 Jul 2015 14:58:22 -0000
From: "no-reply@asdf.ro" <no-reply@asdf.ro>
Subject: Test Report
To: "Test test" <sebi.ciuca@asdf.ro>
Content-Type: Multipart/Alternative; boundary="wm32hkCMsS=_xUqKLF1OiOMUAOi7ru4ljM"
MIME-Version: 1.0
Date: Wed, 15 Jul 2015 17:58:21 +0300
我用于生成电子邮件的代码是
ExecReport;
var
tMess: TIdMessage;
q: TADOQuery;
Attachment: TIdAttachment;
idtTextPart: TIdText;
fileAttach: string;
subiect: string;
i : Integer;
fName : string;
begin
// FEventLogger.LogMessage( ' Executing ' + IntToStr(FTask.FTaskID) , EVENTLOG_ERROR_TYPE , 0, 2);
//
tMess := TIdMessage.Create;
tMess.Subject := FTask.FDenumire;
tMess.ContentType := 'text/html';
try
q := TADOQuery.Create(nil);
q.Connection := fConn;
q.CommandTimeout := FTask.FTimeout;
q.SQL.Text := FTask.FQueryString;
q.Open;
q.First;
except
on E: Exception do
begin
FEventLogger.LogMessage(' Error! ' + E.Message,
EVENTLOG_ERROR_TYPE, 0, 2);
q.Free;
LogErrorExecution(E.Message);
Exit;
end;
end;
Subiect := FTask.FDenumire;
// dtSource := TDataSource.Create(nil);
// dtSource.dataset := q;
fileAttach := CreateExcelDocument(q,False);
tMess := TIdMessage.Create;
tMess.Clear;
tMess.ContentType := 'Multipart/Alternative';
tMess.Subject := subiect;
idtTextPart := TIdText.Create(tMess.MessageParts, nil);
idtTextPart.ContentType := 'text/plain';
idtTextPart.Body.Add(' ');
idtTextPart := TIdText.Create(tMess.MessageParts, nil);
idtTextPart.ContentType := 'text/html';
Attachment := TIdAttachmentFile.Create(tMess.MessageParts, fileAttach);
if q.RecordCount > 0 then
begin
idtTextPart.Body.Text := '<html><body bgcolor="#DCEEFC">';
if (FTask.FHeaderID <> '') then
begin
idtTextPart.Body.Text := idtTextPart.Body.Text + BuildTable(q);
end;
idtTextPart.Body.Text := idtTextPart.Body.Text + ' </body></html>';
self.SendMail(s, tMess);
end;
q.Close;
q.Free;
end;
最佳答案
如果有附件,内容类型如何为“多部分/替代”? Outlook 不知道您的 xls 文件是什么,因此它会选取它所知道的正文部分 - 纯文本或 HTML,并丢弃它不理解的正文风格 (xls)。
您是否尝试过“多部分/混合”内容类型?这样,您将向 Outlook 发出信号,表明您的 xls 文件是附件,与邮件正文无关。
更新
如果您想要纯文本/html 部分和附件,则消息结构应该是
multipart/mixed
multipart/related
text/plain
text/html
attachment
查看 Outlook 为各种邮件创建的 MIME 结构 - 您可以在 OutlookSpy 中看到它(我是它的作者)- 选择与您想要的类似的邮件,单击 OutlookSpy 工具栏上的 IConverterSession 按钮,然后单击 MAPIToMIMEStm。
关于delphi - 使用 Indy 发送电子邮件不会在 Outlook 中显示附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31446612/
我尝试使用SHA-256加密功能,但没有成功。 我需要获取字符串和文件的哈希值。我使用 Delphi 10.1 Berlin 和 Indy for Hash。 我的代码: uses System.Cl
是否有关于如何在 Lazarus 中安装 Indy 10 组件的分步指南? 我在 https://svn.atozed.com:444/svn/Indy10 查看了最后一个 snv 快照 用户名:In
我在 Delphi 7 中编写了一个程序(包括一个使用 Indy 的 ModBus 组件)。在我的机器上,它使用 Indy 9 并且工作正常。它通过 ModBus 协议(protocol)与其他机器进
我是 indy 新手,使用 CBuilder XE4 附带的任何版本。这是非常简单的代码,在我正在阅读的内容超过 16K 限制之前都可以正常工作...... String Ttcp_mgr::send
我在 4 个基于 ubuntu 的机器上设置了 4 个节点。我使用以下命令生成了这些节点所需的 key :init_indy_node VAL1 0.0.0.0 9701 0.0.0.0 9702 1
当前应用程序:Delphi 2006、indy9(大量使用 SOAP 和其他组件) 需要转到 Indy 10 以获得 TLS 支持(poodle 等)。 看着 http://www.indyproje
我是 C++ Builder 的新手。三天前,我安装了 Embarcadero®。 C++Builder® 2010。这门语言对我来说非常有趣。 在 Delphi 中,我通常使用 Indy 9 和 1
我对 SSL 和这些加密的东西完全陌生,但我需要让在移动设备上运行的客户端和服务器 Delphi XE6 应用程序进行通信。必须对 TCP 通信进行安全加密。 首先,我简单地编写了基于 Win32 客
我有三个问题: 是否可以通过多个连接破坏IdTCPServer? 我尝试测试我的应用程序,并且当我有多个连接时 - 它工作得很好(甚至几天),但是当有时连接数增加时,应用程序会导致访问冲突。我写的应用
我使用 Delphi XE 5/6,默认 Indy 版本,Windows 7。IdMappedPortTCP(放在表单上的组件)将本地流从 FFmpeg 重定向到 Twitch.tv,并且总是接近 2
我有一个客户端应用程序,它应该向可选的服务器应用程序发送通知消息。客户端不应受到服务器应用程序是否存在的影响。它应该尝试连接到服务器应用程序并发送通知消息,如果出现错误,它应该默默地忽略所有错误并继续
我在使用Indy(idTCPServer组件)读取客户端发送的数据时遇到一些问题,数据本身是十六进制格式的,所以我不能使用AThread.Connection.ReadLn( );为此... 这是我的
当Indy收到404时,我无法获取响应内容,它总是空的。 例如使用Indy访问https://www.etsy.com/people/car ,我收到 404 并且内容流(或分配的流)只是空的。对TH
很久以前,我使用 Delphi 2007 和 WebBroker (TWebModule) 启动了一些“Web 应用程序”。当时我假设您需要一个 Web 服务器(例如 Apache 或 Microso
这是我的程序: Application.FTP.Host:= vHost; Application.FTP.Port:= vPort; try Application.FTP.AutoLogin
以下代码请求 OAuth2 token 。它适用于 Indy 10.0.52,但对于 Indy 10 SVN 5412,由于请求凭据无效,它会生成 400 Bad Request 错误。 WXYZUs
我有一个应用程序需要从网络驱动器进行一些 FTP 上传。我为此使用 Indy。然后,当文件位于网络驱动器上并成功上传到 FTP 服务器时,我想通过电子邮件将同一文件发送给同事。 我正在使用下面的代码来
我正在使用 Indy UDP Server 读取一串数据。但是,我真的不知道如何使用 Adata 参数。我可以通过使用下面的 ByteToBin 函数将其转换为二进制,然后使用 BintoHex1 将
我是独立服务器的新手,所以我正在努力完成这个简单的任务。我必须创建一个服务器并上传一个小文件;它的大小始终为 128 字节。然后,当有人打开服务器主页时,文件会自动发送。所以: 在磁盘上上传一个文件(
我正在使用 Delphi 10.0 西雅图。 我想向 UDP 服务器发送请求,然后读取服务器响应,这是一个简单的字符串: Client side:send('12345') server side(o
我是一名优秀的程序员,十分优秀!