Board logo

標題: [發問] 如何以巨集執行mail上傳 [打印本頁]

作者: lone_tiger0303    時間: 2010-7-24 09:02     標題: 如何以巨集執行mail上傳

我想要作一個CommandButton1可以一按就將檔案mail上傳指定帳號
請問巨集程式要如何寫呢
作者: jackdream    時間: 2010-7-24 15:17

回復 1# lone_tiger0303

'以 MS OutLook 寄信(非 OutLook Express)

'若出現 使用者自訂型態尚未定義, 則依以下設定
'工具 --> 設定引用項目 -->MicroSoft Outlook 11.0 object library
'若是Office 2003 是11.0,若是 Office 2002 則是10.0 以下類推
  1. Sub send_mail()
  2.     Dim oltAPP As Outlook.Application
  3.     Dim myMail As MailItem

  4.     Set oltAPP = CreateObject("Outlook.Application")
  5.     Set myMail = oltAPP.CreateItem(olMailItem)

  6.     With myMail
  7.     .Attachments.Add "d:\t1.txt"      '附件(請自行更改路徑)
  8.     .To = "[email protected]"        '收件者信箱
  9.     .BodyFormat = olFormatRichText
  10.     .Body = "這是一封測試信件"        '信件內容
  11.     .Subject = "測試信件"             '信件主旨
  12.     .Send
  13.     End With

  14.     oltAPP.Quit
  15.     Set oltAPP = Nothing
  16.     Set myMail = Nothing
  17. End Sub
複製代碼





歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)