- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用this method从 Delphi 应用程序内部发送带有 PDF 附件的 MAPI 电子邮件。
它会打开一个 MS Outlook“新消息”窗口,其中已附加 pdf 文档和一个空白收件人。
如果您输入普通的电子邮件联系方式,那么一切都会顺利进行。
但是,如果您选择传真收件人,它会出现在我的“已发送邮件”文件夹中,但传送会失败(没有错误,没有 MS Outlook“传送失败”消息,并且不会传送消息)。
“传真收件人”是在 MS Outlook 中设置的,只有一个传真号码。没有电子邮件或任何东西。我们使用faxcore server将这些“传真”路由到 Outlook 收件箱。
如果您look at this image ,我为此联系人填写的唯一字段是标有“商务传真”的字段。
如果我手动(即在我的应用程序之外)创建标准 MS Outlook 电子邮件并选择完全相同的传真收件人,并手动附加完全相同的 PDF,那么一切都会顺利进行。
因此,使用 MAPI 发送传真号码似乎会导致失败。 This post sounds similar, except they get a "message undeliverable" error and I don't.
有人可以给我一些建议吗?
谢谢
更新:如果我使用 MAPI 创建电子邮件,然后手动删除附件,那么它确实可以工作。因此,在 Outlook 中,我可以通过电子邮件将附件发送给传真收件人,但使用 MAPI 会失败。
完整源代码如下:
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function SendEMailUsingMAPI(const Subject, Body, FileName, SenderName,
SenderEMail, RecipientName, RecipientEMail: string): integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses
Mapi;
procedure TForm1.Button1Click(Sender: TObject);
begin
//this will bring up an MS Outlook dialog.
//inside that dialog, if i choose a normal email recipient, it works.
// if i choose a fax recipient, it fails silently.
//if i create the email from w/in outlook, it can go to *either* with success.
SendEmailUsingMAPI(
'Subject', //subject of email
'Body', //body of email text
'c:\my_doc.pdf', //attachment file name
'My name', //sender email name
'myemail@mydomain.com', //sender email address
'', //recipient email name
''); //recipient email address
end;
function TForm1.SendEMailUsingMAPI(const Subject, Body, FileName, SenderName,
SenderEMail, RecipientName, RecipientEMail: string): Integer;
var
Message: TMapiMessage;
lpSender, lpRecipient: TMapiRecipDesc;
FileAttach: TMapiFileDesc;
SM: TFNMapiSendMail;
MAPIModule: HModule;
FileType: TMapiFileTagExt;
begin
FillChar(Message,SizeOf(Message),0);
if (Subject <> '') then begin
Message.lpszSubject := PChar(Subject);
end;
if (Body <> '') then begin
Message.lpszNoteText := PChar(Body);
end;
if (SenderEmail <> '') then
begin
lpSender.ulRecipClass := MAPI_ORIG;
if (SenderName = '') then begin
lpSender.lpszName := PChar(SenderEMail);
end
else begin
lpSender.lpszName := PChar(SenderName);
end;
lpSender.lpszAddress := PChar(SenderEmail);
lpSender.ulReserved := 0;
lpSender.ulEIDSize := 0;
lpSender.lpEntryID := nil;
Message.lpOriginator := @lpSender;
end;
if (RecipientEmail <> '') then begin
lpRecipient.ulRecipClass := MAPI_TO;
if (RecipientName = '') then begin
lpRecipient.lpszName := PChar(RecipientEMail);
end
else begin
lpRecipient.lpszName := PChar(RecipientName);
end;
lpRecipient.lpszAddress := PChar(RecipientEmail);
lpRecipient.ulReserved := 0;
lpRecipient.ulEIDSize := 0;
lpRecipient.lpEntryID := nil;
Message.nRecipCount := 1;
Message.lpRecips := @lpRecipient;
end
else begin
Message.lpRecips := nil;
end;
if (FileName = '') then begin
Message.nFileCount := 0;
Message.lpFiles := nil;
end
else begin
FillChar(FileAttach,SizeOf(FileAttach),0);
FileAttach.nPosition := Cardinal($FFFFFFFF);
FileAttach.lpszPathName := PChar(FileName);
FileType.ulReserved := 0;
FileType.cbEncoding := 0;
FileType.cbTag := 0;
FileType.lpTag := nil;
FileType.lpEncoding := nil;
FileAttach.lpFileType := @FileType;
Message.nFileCount := 1;
Message.lpFiles := @FileAttach;
end;
MAPIModule := LoadLibrary(PChar(MAPIDLL));
if MAPIModule = 0 then begin
Result := -1;
end
else begin
try
@SM := GetProcAddress(MAPIModule,'MAPISendMail');
if @SM <> nil then begin
Result := SM(0,Application.Handle,Message,
MAPI_DIALOG or MAPI_LOGON_UI,0);
end
else begin
Result := 1;
end;
finally
FreeLibrary(MAPIModule);
end;
end;
if Result <> 0 then begin
MessageDlg('Error sending mail ('+IntToStr(Result)+').',mtError,[mbOK],0);
end;
end;
end.
最佳答案
好的,您的更新指向附件,所以我将提出另一个猜测:尝试将附件的文件类型明确设置为“application/pdf”(您当前的代码未设置 lpFileType 字段)。传真处理可能取决于此。您可以将 MapiFileTagExt 的编码部分(lpFileType 指向的类型)留空,只需 FillChar 记录并设置 cbTag 和 lpTag 字段。
如果你需要代码(mapi 结构有时可能有点令人眼花缭乱),就大喊吧,但我需要一些时间才能找到时间来输入它。无论如何,再说一次,我只是猜测。我的家庭环境中没有传真设置,否则我会做一些适当的测试。
编辑
说明下面的代码。但是,此后我检查了 Outlook Spy,无论使用哪种方法,还是手动附加文件时,PR_ATTACH_MIME_TAG 属性似乎都是在发送的项目上设置的,而仅在生成的传入消息上设置。
FillChar(FileAttach,SizeOf(FileAttach),0);
FileAttach.nPosition := Cardinal($FFFFFFFF);
FileAttach.lpszPathName := PChar(FileName);
//
MimeType := 'application/pdf';
//
FileType.ulReserved := 0;
FileType.cbTag := Length( MimeType );
FileType.lpTag := PByte(MimeType);
FileType.cbEncoding := 0;
FileType.lpEncoding := nil;
//
FileAttach.lpFileType := @FileType;
Message.nFileCount := 1;
Message.lpFiles := @FileAttach;
(代码格式化程序并不是特别有用)。
关于delphi - 如何将带有附件的 MAPI 电子邮件发送给传真收件人?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1234623/
不要让我开始解释为什么我们必须使用传真,但我们必须这样做。 :( 这就是问题所在。我们使用 Delphi 2010 中的 AsyncPro 传真控件来发送传真。这一切都很好,除了,如果我们在收件人电话
任何人都知道如何使用 Windows 8 Fax true Delphi 发送传真。我的意思是我需要启动带有号码和 pdf 附件的 Windows 传真。有相关教程吗?谢谢。 最佳答案 例如,您可以使
我有一个传真应用程序,我可以使用 API。我一直在尝试将其投入生产。我已经购买了 Office Premium 帐户并放入了新的主线,但没有收到开发团队的任何消息。 此外,关于将应用程序转移到生产环境
我正在使用 Twilio 可编程传真 API 从我的应用程序发送传真消息。当我提供没有任何身份验证的公共(public) URL 作为发送传真的 mediaUrl 时,我在发送传真时不会遇到任何问题。
我有一个传真应用程序,我可以使用 API。我一直在尝试将其投入生产。我已经购买了 Office Premium 帐户并放入了新的主线,但没有收到开发团队的任何消息。 此外,关于将应用程序转移到生产环境
我们有 windows server 2008。每当我们尝试使用 windows 传真和扫描控制台传真 PDF 文档时,adobe reader 实例就会自动打开。如何避免这种情况? 在另一个论坛中给
我想通过 Twilio 仅使用 PHP(如果可能,不使用 JavaScript 或 cron)发送和管理传真来 self 的 linux+Apache+Wordpress 站点。 (开发是在我的本地主
我正在创建一个采用 CCIT4 压缩的 tif 图像。此图像没有 EOFB。有人可以帮助我如何将此 EOFB 添加到 tif 图像中。或者如何使用 EOFB 信息创建图像。 这是我生成没有 EOFB
我以前看过这个问题,但是我没有看到任何明确的答案,而且绝对没有任何答案可以解决我的问题。我创建了一个 Windows 服务来使用 FAXCOMEXLib 库发送传真(半自动)。到目前为止,我的服务已成
我是一名优秀的程序员,十分优秀!