0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

テスト115

Posted at

Sub Mail_Create()
'Excelファイルを添付したメールをメールに添付する
Dim ol As Outlook.Application
Dim MI As Outlook.MailItem
Dim str_Path As String
Dim Attach_Path As String

Set ol = CreateObject("Outlook.Application")
Set MI = ol.CreateItem(olMailItem)

str_Path = "C:\Users\User\Desktop\VBA関連\VBA練習\保存用\test.msg"
Attach_Path = "C:\Users\User\Desktop\VBA関連\VBA練習\保存用\test.xlsx"

'メール各設定
With MI

    .SentOnBehalfOfName = "差出人"    '差出人
    .To = "To宛先"    'TO
    .CC = "CC"    'CC
    .BCC = "BCC"    'BCC
    
    .Subject = "件名"    '件名
    
    '本文
    .Body = "本文テスト"
    
    'メールにテスト用のExcelファイルを添付
    .Attachments.Add Attach_Path
    
    'Excelファイルを添付したメールを保存
    .SaveAs str_Path, olMSG

End With

Set MI = Nothing

'------------------------------
Set MI = ol.CreateItem(olMailItem)

'メール各設定
With MI

    .SentOnBehalfOfName = "差出人"    '差出人
    .To = "To宛先"    'TO
    .CC = "CC"    'CC
    .BCC = "BCC"    'BCC
    
    .Subject = "件名"    '件名
    
    '本文
    .Body = "本文テスト"
    
    '保存したメールファイルを添付
    .Attachments.Add str_Path

    'メール表示
    .Display

End With

Set ol = Nothing
Set MI = Nothing


End Sub
0
0
1

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?