在 VBA 中,我们可以创建一个对象来运行和操作其他应用程序。我正在尝试使用 Excel 中的代码在 Outlook 中做一些工作。
例如 -
With OutMail
.Subject = " Event 1 "
.Importance = True
.Start = "8:00 AM" & Format(Date + 5)
.End = "8:00 AM" & Format(Date + 5)
.Body = "This is a testing event 1 msg " & Format(Date)
.Display
.Save
End With
在这里,我使用了一些我知道的属性,例如 .subject、.start、.save、.display 等。
我很想知道可以使用“with Outlook”命令在 Outlook 中设置的所有属性。
最佳答案
您可以引用this msdn page有关 MailItem 对象的方法和属性的描述。
为了使编写代码更容易,您可以按照 Bathsheba 的建议使用对象浏览器,方法是使用早期绑定(bind)而不是后期绑定(bind)来声明您的 MailItem 实例。为此,请在项目中添加对 Outlook 的引用,方法是单击“工具”--->“引用...”并选中 Microsoft Outlook 14.0 Object Library
旁边的框。 .然后,您可以通过以下方式声明 MailItem:
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem) 'olMailItem is 0
如上所述声明 OutMail 后,VBA IDE 将向您显示对象浏览器中的成员,并在您编写代码时为您提供智能感知。
关于excel - 我可以使用 VBA 分配给 "with Outlook"的所有属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19551883/