返回列表 上一主題 發帖

Excel VBA Outlook body 問題

回復 1# yowhome


   你只要寄出文本內容?
  1. Sub ex()
  2. Set xlOut = CreateObject("Outlook.Application")
  3. '將寄出範圍命名為Rng,取得Rng所有文字
  4. For i = 1 To [Rng].Rows.Count
  5.    For j = 1 To [Rng].Columns.Count
  6.       s = IIf(s = "", [Rng].Cells(i, j), s & Chr(9) & [Rng].Cells(i, j))
  7.    Next
  8.    mystr = IIf(mystr = "", s, mystr & Chr(10) & s)
  9.    s = ""
  10. Next

  11. With xlOut
  12.   Set Mymail = .CreateItem(olMailItem)
  13.   With Mymail
  14.   .Subject = "Mail send test" '信件主旨
  15.   .Recipients.Add "收件者@hotmail.com" '收件者mailaddress
  16.   .Body = mystr '以Rng內容為內文
  17.   .Send '寄出信件
  18.   End With
  19. End With
  20. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 手心向下是助人,手心向上是求人;助人快樂,求人痛苦。
返回列表 上一主題