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

送信問題

答題得分者是:hagar
wll0904
一般會員


發表:5
回覆:5
積分:2
註冊:2003-05-28

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-28 15:58:57 IP:211.21.xxx.xxx 未訂閱
請教各位前輩: 我使用NMSMTP來送信時,若附加檔有好幾個時應如何處理?Attachments中一次只能指定一個附加檔,但我想把2個以上的附加檔一次送出去,請問該如何處理呢?
hagar
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-28 16:23:35 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.
--- --<-<-<@
wll0904
一般會員


發表:5
回覆:5
積分:2
註冊:2003-05-28

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-06 08:44:35 IP:211.21.xxx.xxx 未訂閱
謝謝您的解答!但覺得有點難,沒有使用範例不曉得如何叫用,我最後使用較簡單的方式,先將資料轉到listbox中,再指定附加檔來源為listbox即可一次送多個附加檔出去了.
lesley
一般會員


發表:3
回覆:9
積分:2
註冊:2004-03-29

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-06-09 11:13:48 IP:61.222.xxx.xxx 未訂閱
試試看下面的方法!! for i:=0 to filename.Count-1 do begin NMSMTP.PostMessage.Attachments.Add(filename[i]); end;
系統時間:2024-06-27 0:43:38
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!