VBA/Excel/Access/Word/Outlook/Email Send

Материал из VB Эксперт
Перейти к: навигация, поиск

Send out email

   <source lang="vb">

Sub Send_Msg()

   Dim objOL As New Outlook.Application
   Dim objMail As MailItem
  
   Set objOL = New Outlook.Application
   Set objMail = objOL.CreateItem(olMailItem)
  
   With objMail
       .To = "name@domain.ru"
       .Subject = "Automated Mail Response"
       .Body = "This is an automated message from Excel. " & _
           Format(Range("A1").Value, "$ #,###.#0") & "."
       .Display
   End With
  
   Set objMail = Nothing
   Set objOL = Nothing

End Sub

</source>