我目前的代码通过按下一个按钮创建一个Outlook项目,并根据一定的标准填充电子邮件地址列表。我希望代码还能做的是检查是否有当前打开的邮件项目,然后按下按钮将地址列表添加到.cc项目。我已经尝试了几次迭代,但我完全不知所措。
如果你能帮忙的话,我将不胜感激。
Private Sub CommandButton15_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim emailRng As Range, cl As Range
Dim sTo As String
Set emailRng = Worksheets("Emails").Range("G4:G200")
For Each cl In emailRng
If cl.Value <> "" Then
sTo = sTo & ";" & cl.Offset(, 1).Value
End If
Next
sTo = Mid(sTo, 2)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = sTo
.Display
End With
On Error GoTo 0
End Sub
字符串
1条答案
按热度按时间fslejnso1#
尝试下面的代码,我已经添加了一个
Select Case
,它具有各种逻辑,具体取决于您打开的Outlook邮件的数量。我已经为代码添加了注解,以使其具有一定的意义。字符串