送信問題 |
答題得分者是:hagar
|
wll0904
一般會員 發表:5 回覆:5 積分:2 註冊:2003-05-28 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
不過我沒試過, 嘿嘿!
參考 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 發送簡訊給我 |
|
lesley
一般會員 發表:3 回覆:9 積分:2 註冊:2004-03-29 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |