2012-02-29 20 views
2

私の人生のための1つ以上のブックを送信する方法を理解できません! 1つのワークブックを電子メールで送信する方法がいくつか分かっています。電子メール2つ以上のExcelワークブックVBA

Sub SendActiveWorkbook() 
       ActiveWorkbook.SendMail _ 
    Recipients:=Array("[email protected]", "[email protected]"), _ 
    Subject:="Write subject here"     
End Sub 

そして

Sub RouteActiveWorkbook() 
    With ActiveWorkbook 
      .HasRoutingSlip = True 
       With .RoutingSlip 
        .Delivery = xlAllAtOnce 
        .Recipients = Array("[email protected]", "[email protected]") 
        .Subject = "CSAM Lux BIEO and BCF breakdown" 
        .Message = "Attached are the breakdowns as of " & Date 
       End With 
      .Route 
    End With 
End Sub 

私は与えられたメールに1つのワークブックを送信することができるだけであるように見えます。 (2つのワークブックを1つのワークブックにするために問題は解決しません)。誰でも1通以上のワークブックをメールで送信することで成功しましたか?

答えて

6

希望しますか?

添付ファイルが2つ以上あるメールを送信する基本的な例です。現実的なシナリオに該当する場合は修正してください。ご質問がある場合はお知らせください。また、私は以下の例ではエラー処理の世話をしていません。

は、私は必要なものだけだ

Option Explicit 

Sub Sample() 
    Dim OutApp As Object 
    Dim OutMail As Object 
    Dim MyFileList(1) As String 
    Dim i As Long 

    '~~> Change/Add the file names here 
    MyFileList(0) = "C:\Sample1.xlsm" 
    MyFileList(1) = "C:\Sample2.xlsm" 

    Set OutApp = CreateObject("Outlook.Application") 
    Set OutMail = OutApp.CreateItem(0) 

    With OutMail 
     .To = "[email protected]" 
     .Subject = "Example for attaching 2 files" 
     .Body = "Hi Ommit :)" 

     For i = LBound(MyFileList) To UBound(MyFileList) 
      .Attachments.Add MyFileList(i) 
     Next i 

     .Display 
    End With 
End Sub 
+0

感謝を試してみましたが、テストしました。 – Ommit

関連する問題