this methodを使用して、Delphiアプリケーション内からPDF添付ファイルを含むMAPI電子メールを送信しています。FAX受信者に添付ファイル付きのMAPI電子メールを送信する方法?
これは、既に添付されているPDF文書と空白の受信者のあるMS Outlookの「新しいメッセージ」ウィンドウを表示します。
通常の電子メールの連絡先に入力すると、正常に処理されます。
ただし、FAX受信者を選択すると「送信済みアイテム」フォルダに表示されますが、配信は黙って失敗します(エラーはなく、MS Outlookの「配信に失敗しました」というメッセージも配信されません)。
"ファックス受信者"は、ファックス番号だけでMS Outlookにセットアップされます。メールや何もない。 faxcore serverを使用して、これらの「ファックス」をOutlookの受信トレイにルーティングします。
look at this imageの場合、この連絡先に入力する唯一のフィールドは「ビジネスファクス」とラベルされたフィールドです。
手動で(つまり、アプリケーションの外に)標準のMS Outlookメールを作成し、同じFAX受信者を選択して手動で非常に同じPDFを添付しても問題ありません。
MAPIを使用してFAX番号に送信すると、FAX番号が送信されないことがあります。 This post sounds similar, except they get a "message undeliverable" error and I don't.
誰も私にこの点についていくつか指摘できますか?
おかげ
アップデート:私は電子メールを作成するために、MAPIを使用しますが、その後、私は手動で添付ファイルを削除した場合、それが作業を行います。したがって、Outlook内からは、FAX受信者に添付ファイルを電子メールで送信できますが、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
'[email protected]', //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.
素晴らしい提案 - 私はここにその例を見つけました:http://www.swissdelphicenter.ch/torry/showcode.php?id=1246しかし、それは私にまったく同じ結果をもたらします。 – JosephStyons