1
4

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.

Excel VBAメールを送信

Posted at

はじめに

Excelからマクロ(VBAマクロ)を使って、Outlookアプリケーションを呼び出し、メールを送信する仕組みを実装したい。

やりかた

1.参照設定

  1. [ツール]-[参照設定]にある[Microsoft Outlook 16.0 Object Library]をチェックし、[OK]ボタンをクリックします。

image.png

2.テストメールを送信するSub関数を作ります

Sub testmail()
    Dim appOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem
    
    Set appOutlook = New Outlook.Application
    Set objMail = appOutlook.CreateItem(olMailItem)
    
    With objMail
        .To = "test@test.domain"
        .Subject = "テストメール"
        .Body = "テストメールを送ります。これはExcelマクロから送られました"
        .BodyFormat = olFormatPlain
    End With
    
    objMail.Send
End Sub

これで単純にメールを送信できるようになりました。

参考

1
4
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
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?