全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1826
推到 Plurk!
推到 Facebook!

ShellExecute

尚未結案
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-10-31 15:38:59 IP:61.218.xxx.xxx 未訂閱
var pCh: PChar; begin pCh := 'mailto:mshkolnik@scalabium.com?subject=your_subject&body=your_body&file="c:\autoexec.bat"'; ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL); end; 請問為什麼我的檔案一直夾帶不進來?? 若我要mail給多個人且夾帶多個檔案要如何做??
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-11-01 09:53:59 IP:202.39.xxx.xxx 未訂閱
參考Pegasus的文章(11/05/1997 01:59PM PST): Not sure it's a *small* example, but here's what *I* use! Let me know if I can be of further assistance : )
unit Mapi;
   
interface
   
uses Classes, WinTypes, WinProcs, SysUtils, Dialogs;
   
type
  lpMapiFileDesc = ^TMapiFileDesc;
  TMapiFileDesc = Record
    ulReserved : LongInt;
    flFlags : LongInt;
    nPosition : LongInt;
    lpszPathName : PChar;
    lpszFileName : PChar;
    lpFileType : Pointer;
  end;
   
type
  lpMapiRecipDesc = ^TMapiRecipDesc;
  TMapiRecipDesc = Record
    ulReserved : LongInt;
    ulRecipClass : LongInt;
    lpszName : PChar;
    lpszAddress : PChar;
    ulEIDSize : LongInt;
    lpEntryID : Pointer;
  end;
   
type
  lpMapiMessage = ^TMapiMessage;
  TMapiMessage = Record
    ulReserved : LongInt;
    lpszSubject : PChar;
    lpszNoteText : PChar;
    lpszMessageType : PChar;
    lpszDateReceived : PChar;
    lpszConversationID : PChar;
    flFlags : LongInt;
    lpOriginator : lpMapiRecipDesc;
    nRecipCount : LongInt;
    lpRecips : lpMapiRecipDesc;
    nFileCount : LongInt;
    lpFiles : lpMapiFileDesc;
  end;
   
type
  szString = Array[0..255] of Char;
   
Const
  MAPI_ORIG                     =  0;
  MAPI_TO                       =  1;
  MAPI_CC                       =  2;
  MAPI_BCC                      =  3;
   
  MAPI_LOGON_UI          :LongInt = $0001;
  MAPI_NEW_SESSION       :LongInt = $0002;
  MAPI_DIALOG            :LongInt = $0008;
   
var
  hSession : LongInt;
  EMSubject : String;
  EMText : String;
  EMRecip : Array[0..64] of szString;
  nRecips : LongInt;
  EMFiles : Array[0..64] of szString;
  nFiles : LongInt;
   
  function SendMessage: Integer;
  procedure InitializeMessage;
  procedure AddRecip(name : String);
  procedure AddAttachment(pathname : String);
   
Implementation
   
{ Declare call to MAPI.DLL }
   
Function MAPISendMail(lhSession : LongInt;
                     ulUIParam : LongInt;
                     lpMessage : lpMapiMessage;
                     flFlags : LongInt;
                     ulReserved : LongInt) : LongInt; far;
                             external 'MAPI';
   
procedure InitializeMessage;
var
  i : Integer;
begin
    EMSubject := '';
    EMText := '';
    for i := 0 to 64 do begin
        fillchar(EMRecip[i],255,0);
        fillchar(EMFiles[i],255,0);
    end;
    nRecips := 0;
    nFiles := 0;
end;
   
procedure AddRecip(name : String);
begin
    StrPCopy(@EMRecip[nRecips],name);
    inc(nRecips);
end;
   
procedure AddAttachment(pathname : String);
begin
    StrPCopy(EMFiles[nFiles],pathname);
    inc(nFiles);
end;
   
function SendMessage: Integer;
var
 MMsg       : TMapiMessage;
 Recip      : Array[0..64] of TMapiRecipDesc;
 Attachment : Array[0..64] of TMapiFileDesc;
 szSubject     : szString;
 szText        : szString;
 i : Integer;
 mFlags : LongInt;
begin
 mFlags := MAPI_LOGON_UI;
 FillChar(MMsg,   Sizeof(TMapiMessage),   0);
 FillChar(Recip, Sizeof(TMapiRecipDesc)*64, 0);
 FillChar(Attachment,  Sizeof(TMapiFileDesc)*64,  0);
 MMsg.lpszSubject := StrPCopy(szSubject, EMSubject);
 MMsg.lpszNoteText := StrPCopy(szText, EMText);     If nRecips > 0 then begin
    for i := 0 to nRecips - 1 do begin
       Recip[i].ulRecipClass := MAPI_TO;
       Recip[i].lpszName     := @EMRecip[i];
    end;
    MMsg.nRecipCount    := nRecips;
    MMsg.lpRecips       := @Recip;
    end
 else
    mFlags := mFlags   MAPI_DIALOG;     If nFiles > 0 then
 begin
    for i := 0 to nFiles -1 do begin
    Attachment[i].nPosition    := $ffffffff;
    Attachment[i].lpszPathName := @EMFiles[i];
    end;
    MMsg.nFileCount    := nFiles;
    MMsg.lpFiles       := @Attachment;
 end;     Result := MAPISendMail(hSession, 0, @MMsg, mFlags, 0);
end;
   
end.
-- Everything I say is a lie.
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-11-01 13:08:55 IP:61.218.xxx.xxx 未訂閱
引言: 參考Pegasus的文章(11/05/1997 01:59PM PST): Not sure it's a *small* example, but here's what *I* use! Let me know if I can be of further assistance : )
unit Mapi;
   
interface
   
uses Classes, WinTypes, WinProcs, SysUtils, Dialogs;
   
type
  lpMapiFileDesc = ^TMapiFileDesc;
  TMapiFileDesc = Record
    ulReserved : LongInt;
    flFlags : LongInt;
    nPosition : LongInt;
    lpszPathName : PChar;
    lpszFileName : PChar;
    lpFileType : Pointer;
  end;
   
type
  lpMapiRecipDesc = ^TMapiRecipDesc;
  TMapiRecipDesc = Record
    ulReserved : LongInt;
    ulRecipClass : LongInt;
    lpszName : PChar;
    lpszAddress : PChar;
    ulEIDSize : LongInt;
    lpEntryID : Pointer;
  end;
   
type
  lpMapiMessage = ^TMapiMessage;
  TMapiMessage = Record
    ulReserved : LongInt;
    lpszSubject : PChar;
    lpszNoteText : PChar;
    lpszMessageType : PChar;
    lpszDateReceived : PChar;
    lpszConversationID : PChar;
    flFlags : LongInt;
    lpOriginator : lpMapiRecipDesc;
    nRecipCount : LongInt;
    lpRecips : lpMapiRecipDesc;
    nFileCount : LongInt;
    lpFiles : lpMapiFileDesc;
  end;
   
type
  szString = Array[0..255] of Char;
   
Const
  MAPI_ORIG                     =  0;
  MAPI_TO                       =  1;
  MAPI_CC                       =  2;
  MAPI_BCC                      =  3;
   
  MAPI_LOGON_UI          :LongInt = $0001;
  MAPI_NEW_SESSION       :LongInt = $0002;
  MAPI_DIALOG            :LongInt = $0008;
   
var
  hSession : LongInt;
  EMSubject : String;
  EMText : String;
  EMRecip : Array[0..64] of szString;
  nRecips : LongInt;
  EMFiles : Array[0..64] of szString;
  nFiles : LongInt;
   
  function SendMessage: Integer;
  procedure InitializeMessage;
  procedure AddRecip(name : String);
  procedure AddAttachment(pathname : String);
   
Implementation
   
{ Declare call to MAPI.DLL }
   
Function MAPISendMail(lhSession : LongInt;
                     ulUIParam : LongInt;
                     lpMessage : lpMapiMessage;
                     flFlags : LongInt;
                     ulReserved : LongInt) : LongInt; far;
                             external 'MAPI';
   
procedure InitializeMessage;
var
  i : Integer;
begin
    EMSubject := '';
    EMText := '';
    for i := 0 to 64 do begin
        fillchar(EMRecip[i],255,0);
        fillchar(EMFiles[i],255,0);
    end;
    nRecips := 0;
    nFiles := 0;
end;
   
procedure AddRecip(name : String);
begin
    StrPCopy(@EMRecip[nRecips],name);
    inc(nRecips);
end;
   
procedure AddAttachment(pathname : String);
begin
    StrPCopy(EMFiles[nFiles],pathname);
    inc(nFiles);
end;
   
function SendMessage: Integer;
var
 MMsg       : TMapiMessage;
 Recip      : Array[0..64] of TMapiRecipDesc;
 Attachment : Array[0..64] of TMapiFileDesc;
 szSubject     : szString;
 szText        : szString;
 i : Integer;
 mFlags : LongInt;
begin
 mFlags := MAPI_LOGON_UI;
 FillChar(MMsg,   Sizeof(TMapiMessage),   0);
 FillChar(Recip, Sizeof(TMapiRecipDesc)*64, 0);
 FillChar(Attachment,  Sizeof(TMapiFileDesc)*64,  0);
 MMsg.lpszSubject := StrPCopy(szSubject, EMSubject);
 MMsg.lpszNoteText := StrPCopy(szText, EMText);     If nRecips > 0 then begin
    for i := 0 to nRecips - 1 do begin
       Recip[i].ulRecipClass := MAPI_TO;
       Recip[i].lpszName     := @EMRecip[i];
    end;
    MMsg.nRecipCount    := nRecips;
    MMsg.lpRecips       := @Recip;
    end
 else
    mFlags := mFlags   MAPI_DIALOG;     If nFiles > 0 then
 begin
    for i := 0 to nFiles -1 do begin
    Attachment[i].nPosition    := $ffffffff;
    Attachment[i].lpszPathName := @EMFiles[i];
    end;
    MMsg.nFileCount    := nFiles;
    MMsg.lpFiles       := @Attachment;
 end;     Result := MAPISendMail(hSession, 0, @MMsg, mFlags, 0);
end;
   
end.
-- Everything I say is a lie.
小妹愚笨,可以寫個範例給我參考如何使用以上的function??
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-11-01 14:16:13 IP:61.218.xxx.xxx 未訂閱
我將use 此Unit 程式碼如下 var i: integer; begin EMSubject :='test'; EMText := 'test body'; AddRecip('ling@khl.com.tw'); AddRecip('yedda@khl.com.tw'); AddAttachment('c:\temp\aa.txt'); AddAttachment('c:\temp\bb.txt'); i:=SendMessage; end; 但是出現無法找到動態連結程式庫MAPI,請問是否我哪裡做錯??
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-11-01 14:30:36 IP:202.39.xxx.xxx 未訂閱
1.ShellExecute 的方要 MS Outlook 才有支援 2.找不到可聯結的動態函式庫, 您有安裝 MAPI 嗎? 小弟想應該是找不到 MAPI.dll 檔    -- Everything I say is a lie.
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-11-01 16:15:38 IP:61.218.xxx.xxx 未訂閱
引言: 1.ShellExecute 的方要 MS Outlook 才有支援 2.找不到可聯結的動態函式庫, 您有安裝 MAPI 嗎? 小弟想應該是找不到 MAPI.dll 檔 -- Everything I say is a lie.
有啊,我的電腦有找到MAPI.DLL,在winnt\system32下,是要如何使用呢??
系統時間:2024-04-16 20:12:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!