【发布时间】:2013-11-26 03:59:41
【问题描述】:
我正在尝试在一系列单元格中添加多个收件人的电子邮件。
我可以选择工作表上的电子邮件范围。
但是,我不断收到此不匹配错误,我不知道如何解决。
我一直在寻找解决方案并采取了相同的步骤。
请原谅我,我是 VBA 新手。 非常感谢您的帮助。 我的代码如下,
Private Sub CommandButton1_Click()
Dim olapp As Object
Dim olmail As Object
Dim recip As String
lastr = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
'this is for the range of data to be copied on the body but have yet to do it
lastr2 = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 7).End(xlUp).Row
recip = ThisWorkbook.Sheets("Sheet1").Range("G3:G" & lastr2).Value
'mismatch after this step
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(0)
With MItem
.to = recip
.Subject = "hello"
.Body = "whats up"
.display
End With
知道为什么会这样吗?
【问题讨论】: