0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【ExcelVBA×Outlook】ExcelからOutlookメールを送信する

Last updated at Posted at 2021-06-03
Function outlook_send_mail(ByVal meAddress As String, ByVal toAddress As String, ByVal ccAddress As String, ByVal bccAddress As String, ByVal subject As String, ByVal body As String) As Variant

    Dim outlookObj As Outlook.Application
    Dim mailItemObj As Outlook.mailItem
    
    Dim i As Long
    
    Set outlookObj = CreateObject("Outlook.Application")
    Set mailItemObj = outlookObj.CreateItem(olMailItem)
    mailItemObj.BodyFormat = 3      'リッチテキストに変更
    mailItemObj.SentOnBehalfOfName = meAddress
    mailItemObj.To = toAddress
    mailItemObj.cc = ccAddress
    mailItemObj.BCC = bccAddress
    mailItemObj.subject = subject
    mailItemObj.body = body

    mailItemObj.Send

    Set outlookObj = Nothing
    Set mailItemObj = Nothing

End Function
Function outlook_display_mail(ByVal meAddress As String, ByVal toAddress As String, ByVal ccAddress As String, ByVal bccAddress As String, ByVal subject As String, ByVal body As String) As Variant

    Dim outlookObj As Outlook.Application
    Dim mailItemObj As Outlook.mailItem
    
    Dim i As Long
    
    Set outlookObj = CreateObject("Outlook.Application")
    Set mailItemObj = outlookObj.CreateItem(olMailItem)
    mailItemObj.BodyFormat = 3      'リッチテキストに変更
    mailItemObj.SentOnBehalfOfName = meAddress
    mailItemObj.To = toAddress
    mailItemObj.cc = ccAddress
    mailItemObj.BCC = bccAddress
    mailItemObj.subject = subject
    mailItemObj.body = body

    mailItemObj.Display

    Set outlookObj = Nothing
    Set mailItemObj = Nothing

End Function
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?