Help us understand the problem. What is going on with this article?

VBAからOutlookを使ってメールを送信するサンプル(添付に対応)

More than 1 year has passed since last update.
test.xlsm
Sub test()

    '宣言
    Dim outlook        As Object
    Dim mail_to        As String
    Dim mail_cc        As String
    Dim mail_subject   As String
    Dim mail_body      As String
    Dim mail_file_path As String

    '代入
    Set outlook    = CreateObject("Outlook.Application")
    mail_to        = "sozaiya@dummy.com"
    mail_cc        = "info@dummy.com"
    mail_subject   = "test"
    mail_body      = "テストです。"

    '空白だったら添付ファイルなしと判定
    mail_file_path = "C:\Users\xxxx\Desktop\test.txt"

    With outlook.CreateItem(0)
        .to      = mail_to
        .cc      = mail_cc
        .Subject = mail_subject
        .body    = mail_body
        If mail_file_path <> "" Then .Attachments.Add mail_file_path

        '送信確認画面を表示
        .display

        'いきなり送信
        .send
    End With
End Sub
sozaiya
よろしくお願いします ^^) _旦~~
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした