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

Delphi如何呼叫VBS

尚未結案
terrychen
尊榮會員


發表:90
回覆:794
積分:501
註冊:2003-05-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-24 09:31:28 IP:61.221.xxx.xxx 未訂閱
請教各位前輩 小弟再使用SHELLEXCUTE呼叫OUTLOOK時 無法做到附加檔案的動作 故希望轉藉VBS來完成附加檔案的動作 所以希望有前輩能提供關於呼叫VBS的方法或範例以供參考
terrychen
尊榮會員


發表:90
回覆:794
積分:501
註冊:2003-05-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-24 10:53:25 IP:61.221.xxx.xxx 未訂閱
小弟使用另一ㄍ方法
procedure TForm2.SendMail;
var
  Outlook: variant;{ Application }
  OutlookNameSpace: variant;{ NameSpace }
  OutlookFolder: variant;{ MAPIFolder }
  OutlookMailItem: variant;{ MailItem }
  OutlookRecipient,OutlookReciepientItem: variant;{ Recipient }
  OutlookAttachment: variant;{ Attachment }    begin
  try
    Outlook:=CreateOleObject('Outlook.Application');
  except
    ShowMessage('無法?動Microsoft Outlook!');
    Exit;
  end;
  try
    OutlookNameSpace := Outlook.GetNamespace('MAPI');
    { 創建新郵件消息 }
    //
    OutlookFolder := OutlookNameSpace.GetDefaultFolder(olFolderOutbox);
    //增加收件人若地址薄中已有此人,則僅用其名字即可,否則必須包括完整地址,如OutlookNameSpace.CurrentUser.Address}
    OutlookMailItem := OutlookFolder.Items.Add(olMailItem);
    OutlookRecipient := OutlookMailItem.Recipients.Add('ZhangChunming');
    OutlookRecipient.Type := olTo;
    if not OutlookRecipient.Resolve then
    begin
      ShowMessage('無法解析地址!');
      Exit;
    end;
    { 插入附件(確保路徑正確) }
    OutlookAttachment := OutlookMailItem.Attachments.Add('c:\1120.XLS');
    OutlookAttachment.DisplayName := '樣本附件';
    { 設置郵件主題、郵件正文和重要性 }
    OutlookMailItem.Subject := '郵件主題';
    OutlookMailItem.Body := '此處?郵件內容';
    OutlookMailItem.Importance := olImportanceHigh;
    OutlookMailItem.Send;
    Showmessage('郵件已送出');
  finally
    OutlookRecipient := Unassigned;
    OutlookAttachment := Unassigned;
    OutlookMailItem := Unassigned;
    OutlookFolder := Unassigned;
    OutlookNameSpace := Unassigned;
    Outlook := Unassigned;
  end;
end;
是由jackkcg兄所發表 執行沒出現錯誤,但似乎郵件也沒有寄出 試了好久,請各位前輩指點一下 P.S小弟使用的是D6不知跟版本有無關係 發表人 - Terrychen 於 2003/11/24 10:57:29
william
版主


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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-24 11:01:08 IP:218.190.xxx.xxx 未訂閱
1) Wrong board... 2) Component|Import ActiveX control and choose Microsoft Script Control. You need to have Windows Script Host installed (installed as default in XP) and download it for Windows 9x.
terrychen
尊榮會員


發表:90
回覆:794
積分:501
註冊:2003-05-01

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-24 13:48:23 IP:61.221.xxx.xxx 未訂閱
william版主您好 那有適合D6的方式ㄇ 小弟使用的作業系統是windows xp
系統時間:2024-05-18 16:13:29
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!