返回列表 上一主題 發帖

[發問] 如何以巨集執行mail上傳

[發問] 如何以巨集執行mail上傳

我想要作一個CommandButton1可以一按就將檔案mail上傳指定帳號
請問巨集程式要如何寫呢

回復 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 = "test123@ttt.com.tw"        '收件者信箱
  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
複製代碼

TOP

        靜思自在 : 改變自己是自救,影響別人是救人。
返回列表 上一主題