Loop vba同时显示各种电子邮件

时间:2017-03-22 10:43:15

标签: excel vba excel-vba outlook outlook-vba

用WINRAR压缩10MB部分文件。我想循环并创建一个附加每个部分的电子邮件,并在发送之前显示所有电子邮件。

Set OutApp = CreateObject("Outlook.Application")

Application.Wait (Now + TimeValue("0:00:30"))
On Error GoTo 0
Set OutMail = OutApp.CreateItem(0)
For i = 1 To times
    With OutMail
        .To = wb1.Sheets("MAIL").Cells(4, 3).Value
        .CC = wb1.Sheets("MAIL").Cells(5, 3).Value
        .BCC = ""
        .Subject = wb1.Sheets("MAIL").Cells(6, 3).Value
        .Body = wb1.Sheets("MAIL").Cells(9, 3).Value
        'You can add other files also like this

            If (times > 1) Then
                .Attachments.Add source & "part" & i & ".rar"
            Else: .Attachments.Add source & "rar"
            End If
        '.Send   'or use .Display

        .Display
    End With
Next i
  1. 如果我用"。发送"它会发送一封没有任何附件的电子邮件。
  2. 如果我使用"。显示"它在outlook中显示1封电子邮件,随时可以发送 附上所有零件。 (在我的例子中有3个部分)。
  3. 我要么:

    • 发送3封电子邮件,每封发送1份文件 OR
    • 显示3封电子邮件,每封都附有1部分,随时可以点击"发送" 在Outlook中。

    我希望我自己解释一下。

1 个答案:

答案 0 :(得分:1)

您只是错过了创建新邮件的部分 Scanning dependencies of target unitconverter [ 95%] Building CXX object H08-unit-converter/CMakeFiles/unitconverter.dir/src/unitconverter.cxx.o /unitconverter.cxx: In instantiation of ‘static const M1 Measure_add<M1, M2>::value() [with M1 = Measure<10, (Unit)2>; M2 = Measure<10, (Unit)2>]’: /unitconverter.cxx:112:62: required from here /unitconverter.cxx:78:63: error: could not convert ‘Measure<20, (Unit)2>()’ from ‘Measure<20, (Unit)2>’ to ‘const Measure<10, (Unit)2>’ return Measure<(M1::value + M2::value), M1::unit>(); ^ /unitconverter.cxx:84:78: error: the value of ‘difference’ is not usable in a constant expression return Measure<(M1::value + (M2::value * difference)), M1::unit>(); ^ /unitconverter.cxx:82:19: note: ‘difference’ was not initialized with a constant expression int const difference = Measure_difference<M1,M2>::value(); ^ /unitconverter.cxx:84:78: note: in template argument for type ‘int’ return Measure<(M1::value + (M2::value * difference)), M1::unit>(); ^ /unitconverter.cxx:87:78: error: the value of ‘difference’ is not usable in a constant expression return Measure<(M2::value + (M1::value * difference)), M2::unit>(); ^ /unitconverter.cxx:82:19: note: ‘difference’ was not initialized with a constant expression int const difference = Measure_difference<M1,M2>::value(); ^ /unitconverter.cxx:87:78: note: in template argument for type ‘int’ return Measure<(M2::value + (M1::value * difference)), M2::unit>(); ^
循环内的 ,如下所示:

Set OutMail = OutApp.CreateItem(0)