我正在尝试引用另一个工作簿中的单元格A1,在某个工作表中,将其设置为电子邮件中的“收件人”字段。这是我的代码:
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Addresses = Workbooks("Test.xlsx").Sheets("Sheet2").Range("A1").Value
On Error Resume Next
With OutMail
.to = Addresses
.CC = ""
.BCC = ""
.Subject = "Confirm " & Format(Date, "mm.dd.yy")
.body = "Please see attached for your confirm. Thanks,"
.Attachments.add ActiveWorkbook.FullName
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
当我执行宏时,电子邮件中的“收件人”字段中没有任何内容。我引用的单元格肯定有一个值。有没有人有任何建议?
答案 0 :(得分:1)
尝试将display
移至开头。所以...
With OutMail
.display