1

我目前有一个 VBA 代码,它选择一个自定义范围,然后将所述选定范围通过电子邮件发送到我在另一个工作表中的电子邮件列表中。我附上了代码,但是这段代码被复制和粘贴了 8 次(有 8 个块)......如果这很重要,我想我应该提供尽可能多的信息。这是我的两个问题:

1)如何在 Outlook 上显示电子邮件窗口而不是自动发送(我已经尝试过 .Item.Display 并且它不起作用,所以请推荐任何替代方案或任何其他方法) 2)如何让所选范围保持其格式(有些文本是红色的,但一旦在电子邮件中发送,就会显示为默认文本)。

提前致谢。

     For Each aCell In Worksheets("Email List").Range("B3:B" & Cells(Rows.Count, "B").End(xlUp).Row)
            If aCell <> "" Then
                    eTo = eTo & aCell & ";"
                End If
    Next
     eTo = Left(eTo, Len(eTo) - 1)
   If IsEmpty(Range("B4")) Then
   Else
      ActiveSheet.Range("a3", ActiveSheet.Range("e3").End(xlDown)).Select
      ActiveWorkbook.EnvelopeVisible = True
   With ActiveSheet.MailEnvelope

      .Item.To = eTo
      .Item.Subject = "Allocations -  Barclays" & Format(Date, " mm/dd/yyyy")
      .Item.Send
   End With
   End If
4

1 回答 1

3

我使用它并且它有效 - 这会显示邮件,但可以更改:

With OutMail
        .To = mailName ' This is the name of the person to review the documents.
        .CC = ""
        .BCC = ""
        .Subject = "Please review the attached."
        .HTMLBody = RangetoHTML(rng)
        .Display   'or use .Send
    End With

看看http://www.rondebruin.nl/win/s1/outlook/bmail2.htm 这有关于从 excel 发送带有 Outlook 的范围的极好信息。

于 2013-10-22T23:42:18.093 回答