繁体   English   中英

引用另一个工作簿中的单元格作为.To字段中的电子邮件地址

[英]Reference cell in another workbook as email address in .To field

我试图在另一张工作簿中的某个工作表中引用单元格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

当我执行宏时,电子邮件中的“收件人”字段中没有任何内容。 我所引用的单元格肯定具有价值。 有没有人有什么建议?

尝试将display移到开头。 所以...

With OutMail

    .display

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM