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

如何判斷目前預設的郵件程式是outlook Express or outlook 2000

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


發表:10
回覆:26
積分:7
註冊:2002-07-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-09 14:01:38 IP:61.222.xxx.xxx 未訂閱
請問如何判斷目前預設的郵件程式是outlook Express or outlook 2000 或其他程式的程式名稱和程式路徑嗎!? 因為我現在想寫一支delphi程式能夠選擇檔案儲存或傳送,在傳送的部分想看能不能直接取得regedit的設定(有關按右鍵選擇傳送郵件時會自動開起預設outlook並且執行新郵件且已加入夾檔)。
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-09 14:19:43 IP:147.8.xxx.xxx 未訂閱
HKEY_CLASSES_ROOT\mailto\shell\open\command    http://www.winguides.com/registry/display.php/1263/
fanny
一般會員


發表:10
回覆:26
積分:7
註冊:2002-07-19

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-09 16:56:55 IP:61.222.xxx.xxx 未訂閱
引言: Thanks~~ 可是我還是不會用 假如我現在按下button 會執行以下的動作 if not DirectoryExists('c:\temp') then if not CreateDir('C:\temp') then raise Exception.Create('Cannot create c:\temp'); xFileStream := TFileStream.Create('c:\temp\temp.txt', fmCreate); Reg := TRegistry.Create; Reg.RootKey :=HKEY_CLASSES_ROOT; skey := '\mailto\shell\open\command'; Reg.OpenKey(skey,false); NetSet := Reg.ReadString(''); 接下來我要如何開啟一個新郵件並已插入temp.txt檔案
hagar
版主


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-09 17:18:13 IP:202.39.xxx.xxx 未訂閱
參考這篇吧: http://forum.vclxx.org/topic.php?TOPIC_ID=17826&FORUM_ID=5&CAT_ID=2&Topic_Title=ShellExecute%A5l%B3%EAOutLook%AE%C9%A1A%A6p%A6%F3%A6P%AE%C9%B1N%2A%2Ehtm%A5%E1%A4J&Forum_Title=Database    --- 每個人都是一本書
jackkcg
站務副站長


發表:891
回覆:1050
積分:848
註冊:2002-03-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-05-09 17:29:34 IP:61.221.xxx.xxx 未訂閱
這個也可以參考看看 【問題】如何取得目前outlook Express的郵件的目錄 http://delphi.ktop.com.tw/topic.php?topic_id=23385 ********************************************************* 哈哈&兵燹 最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好 Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知 K.表Knowlege 知識,就是本站的標語:Open our mind to make knowledge together! 希望能大家敞開心胸,將知識寶庫結合一起
------
**********************************************************
哈哈&兵燹
最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好

Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知
K.表Knowlege 知識,就是本站的標語:Open our mind
fanny
一般會員


發表:10
回覆:26
積分:7
註冊:2002-07-19

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-05-09 18:46:40 IP:61.222.xxx.xxx 未訂閱
謝謝各位熱心的幫助 感激不盡 Thanks~~
fanny
一般會員


發表:10
回覆:26
積分:7
註冊:2002-07-19

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-05-12 11:48:30 IP:61.222.xxx.xxx 未訂閱
hanger你好: 很感謝你的協助,可是為何我上星期寫的程式可以啟動outlook可是今天每次執行Outlook := GetActiveOleObject('Outlook.Application') 就會出現錯誤訊息【Project outlook.exe raised exeception class EOleSysError with message'操作無法使用'. Process stopped. Use Step or Run to continum.】。我是哪裡沒設定好? Thanks~~
hagar
版主


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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-05-12 14:05:03 IP:202.39.xxx.xxx 未訂閱
通常的寫法如下:
begin
  try
    Outlook := GetActiveOleObject('Outlook.Application');
  except
    Outlook := CreateOleObject('Outlook.Application');
  end;
end;
如果您在 IDE 上 run, 會出現錯誤訊息是正常的 只要直接執行 exe 檔就不會了 或者在 Tools -> Debugger Options 的 Language Exceptions 頁中 底下有個 Stop on Delphi exceptions 的 Checkbox 將它取消即可. --- 每個人都是一本書
fanny
一般會員


發表:10
回覆:26
積分:7
註冊:2002-07-19

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-05-13 17:56:06 IP:61.222.xxx.xxx 未訂閱
不好意思 再請問一下 如果我現在要改用winexec執行 如果預設的outlook是microsoft outlook 我可以取得機碼"%ProgramFiles%\Outlook Express\msimn.exe" /mailurl:%1 用winexec執行只需將%1改為要加入的檔案即可 可是如果預設是outlook express 取得的機碼是"%ProgramFiles%\Outlook Express\msimn.exe" /mailurl:%1 用winexec要如何改?只改%1會出現無法開啟url的錯誤訊息 若都不改則會開一封空白的郵件要如何加入夾檔?
hagar
版主


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

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-05-13 18:35:42 IP:202.39.xxx.xxx 未訂閱
參考這篇 http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20360531.html 轉貼如下: 
unit Unit1;
   
interface
   
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
   
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
   
var
  Form1: TForm1;
   
implementation
   
uses MAPI;
   
{$R *.DFM}
   
function SendEMail(Handle: THandle; Mail: TStrings): Cardinal; 
type 
  TAttachAccessArray = array [0..0] of TMapiFileDesc; 
  PAttachAccessArray = ^TAttachAccessArray; 
var 
  MapiMessage: TMapiMessage; 
  Receip: TMapiRecipDesc; 
  Attachments: PAttachAccessArray; 
  AttachCount: Integer; 
  i1: integer; 
  FileName: string; 
  dwRet: Cardinal; 
  MAPI_Session: Cardinal; 
  WndList: Pointer; 
begin 
  dwRet := MapiLogon(Handle, PChar(''), PChar(''), 
   MAPI_LOGON_UI or MAPI_NEW_SESSION, 0, @MAPI_Session); 
   
  if (dwRet <> SUCCESS_SUCCESS) then begin 
    MessageBox(Handle, 
      PChar('Error while trying to send email'), 
      PChar('Error'), 
      MB_ICONERROR or MB_OK); 
  end else begin 
    FillChar(MapiMessage, SizeOf(MapiMessage), #0); 
    Attachments := nil; 
    FillChar(Receip, SizeOf(Receip), #0); 
   
    if Mail.Values['to'] <> '' then begin 
      Receip.ulReserved := 0; 
      Receip.ulRecipClass := MAPI_TO; 
      Receip.lpszName := StrNew(PChar(Mail.Values['to'])); 
      Receip.lpszAddress := StrNew(PChar('SMTP:' + Mail.Values['to'])); 
      Receip.ulEIDSize := 0; 
      MapiMessage.nRecipCount := 1; 
      MapiMessage.lpRecips := @Receip; 
    end; 
   
    AttachCount := 0;
   
    for i1 := 0 to MaxInt do begin 
      if Mail.Values['attachment' + IntToStr(i1)] = '' then 
        break; 
      Inc(AttachCount); 
    end; 
   
    if AttachCount > 0 then begin 
      GetMem(Attachments, SizeOf(TMapiFileDesc) * AttachCount); 
   
      for i1 := 0 to AttachCount - 1 do begin 
        FileName := Mail.Values['attachment' + IntToStr(i1)]; 
        Attachments[i1].ulReserved := 0; 
        Attachments[i1].flFlags := 0; 
        Attachments[i1].nPosition := ULONG($FFFFFFFF); 
        Attachments[i1].lpszPathName := StrNew(PChar(FileName)); 
        Attachments[i1].lpszFileName := 
         StrNew(PChar(ExtractFileName(FileName))); 
        Attachments[i1].lpFileType := nil; 
      end; 
      MapiMessage.nFileCount := AttachCount; 
      MapiMessage.lpFiles := @Attachments^; 
    end; 
   
    if Mail.Values['subject'] <> '' then 
      MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject']));
    if Mail.Values['body'] <> '' then 
      MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body'])); 
   
    WndList := DisableTaskWindows(0); 
    try 
      Result := MapiSendMail(MAPI_Session, Handle, 
      MapiMessage, MAPI_DIALOG, 0); 
    finally 
      EnableTaskWindows( WndList ); 
    end; 
   
    for i1 := 0 to AttachCount - 1 do begin 
      StrDispose(Attachments[i1].lpszPathName); 
      StrDispose(Attachments[i1].lpszFileName); 
    end; 
   
    if Assigned(MapiMessage.lpszSubject) then 
      StrDispose(MapiMessage.lpszSubject); 
    if Assigned(MapiMessage.lpszNoteText) then 
      StrDispose(MapiMessage.lpszNoteText); 
    if Assigned(Receip.lpszAddress) then 
      StrDispose(Receip.lpszAddress); 
    if Assigned(Receip.lpszName) then 
      StrDispose(Receip.lpszName); 
    MapiLogOff(MAPI_Session, Handle, 0, 0); 
  end; 
end; 
   
procedure TForm1.Button1Click(Sender: TObject);
var 
  mail: TStringList; 
begin 
  mail := TStringList.Create; 
  try 
    mail.values['to'] := 'Receiver-Email@test.xyz'; 
    mail.values['subject'] := 'Hello'; 
    mail.values['body'] := 'blah'; 
    mail.values['body'] := 'blah'; 
    mail.values['attachment0'] := 'C:\Test1.'; 
    // mail.values['attachment1']:='C:\Test2.txt'; 
    SendEMail(Application.Handle, mail); 
  finally 
    mail.Free; 
  end; 
end;
     
end.
--- 每個人都是一本書
sundy6719
初階會員


發表:136
回覆:78
積分:42
註冊:2002-07-10

發送簡訊給我
#11 引用回覆 回覆 發表時間:2005-10-20 14:25:48 IP:211.74.xxx.xxx 未訂閱
hagar 您好我把您的程式碼打入我的程式內可是怎麼都沒有任何東西跑出來呢謝謝 unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses MAPI; {$R *.DFM} function SendEMail(Handle: THandle; Mail: TStrings): Cardinal; type TAttachAccessArray = array [0..0] of TMapiFileDesc; PAttachAccessArray = ^TAttachAccessArray; var MapiMessage: TMapiMessage; Receip: TMapiRecipDesc; Attachments: PAttachAccessArray; AttachCount: Integer; i1: integer; FileName: string; dwRet: Cardinal; MAPI_Session: Cardinal; WndList: Pointer; begin dwRet := MapiLogon(Handle, PChar(''), PChar(''), MAPI_LOGON_UI or MAPI_NEW_SESSION, 0, @MAPI_Session); if (dwRet <> SUCCESS_SUCCESS) then begin MessageBox(Handle, PChar('Error while trying to send email'), PChar('Error'), MB_ICONERROR or MB_OK); end else begin FillChar(MapiMessage, SizeOf(MapiMessage), #0); Attachments := nil; FillChar(Receip, SizeOf(Receip), #0); if Mail.Values['to'] <> '' then begin Receip.ulReserved := 0; Receip.ulRecipClass := MAPI_TO; Receip.lpszName := StrNew(PChar(Mail.Values['to'])); Receip.lpszAddress := StrNew(PChar('SMTP:' Mail.Values['to'])); Receip.ulEIDSize := 0; MapiMessage.nRecipCount := 1; MapiMessage.lpRecips := @Receip; end; AttachCount := 0; for i1 := 0 to MaxInt do begin if Mail.Values['attachment' IntToStr(i1)] = '' then break; Inc(AttachCount); end; if AttachCount > 0 then begin GetMem(Attachments, SizeOf(TMapiFileDesc) * AttachCount); for i1 := 0 to AttachCount - 1 do begin FileName := Mail.Values['attachment' IntToStr(i1)]; Attachments[i1].ulReserved := 0; Attachments[i1].flFlags := 0; Attachments[i1].nPosition := ULONG($FFFFFFFF); Attachments[i1].lpszPathName := StrNew(PChar(FileName)); Attachments[i1].lpszFileName := StrNew(PChar(ExtractFileName(FileName))); Attachments[i1].lpFileType := nil; end; MapiMessage.nFileCount := AttachCount; MapiMessage.lpFiles := @Attachments^; end; if Mail.Values['subject'] <> '' then MapiMessage.lpszSubject := StrNew(PChar(Mail.Values['subject'])); if Mail.Values['body'] <> '' then MapiMessage.lpszNoteText := StrNew(PChar(Mail.Values['body'])); WndList := DisableTaskWindows(0); try Result := MapiSendMail(MAPI_Session, Handle, MapiMessage, MAPI_DIALOG, 0); finally EnableTaskWindows( WndList ); end; for i1 := 0 to AttachCount - 1 do begin StrDispose(Attachments[i1].lpszPathName); StrDispose(Attachments[i1].lpszFileName); end; if Assigned(MapiMessage.lpszSubject) then StrDispose(MapiMessage.lpszSubject); if Assigned(MapiMessage.lpszNoteText) then StrDispose(MapiMessage.lpszNoteText); if Assigned(Receip.lpszAddress) then StrDispose(Receip.lpszAddress); if Assigned(Receip.lpszName) then StrDispose(Receip.lpszName); MapiLogOff(MAPI_Session, Handle, 0, 0); end; end; procedure TForm1.Button1Click(Sender: TObject); var mail: TStringList; begin mail := TStringList.Create; try mail.values['to'] := 'Receiver-Email@test.xyz'; mail.values['subject'] := 'Hello'; mail.values['body'] := 'blah'; mail.values['body'] := 'blah'; mail.values['attachment0'] := 'C:\Test1.'; // mail.values['attachment1']:='C:\Test2.txt'; SendEMail(Application.Handle, mail); finally mail.Free; end; end; end.
系統時間:2024-11-23 10:51:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!