我可以使用 VBA 分配给“使用 Outlook”的所有属性是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19551883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are all the properties that I can assign to "with Outlook" with VBA?
提问by devutkarsh
In VBA we can create an object to run and manipulate other applications. I am trying to do a few jobs in Outlook with code in Excel.
在 VBA 中,我们可以创建一个对象来运行和操作其他应用程序。我正在尝试使用 Excel 中的代码在 Outlook 中完成一些工作。
Eg -
例如——
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
Here I have used a few properties I know like .subject, .start, .save, .display etc.
在这里,我使用了一些我知道的属性,例如 .subject、.start、.save、.display 等。
I am interested to know all the properties that I can set in Outlook using the "with Outlook" command.
我很想知道我可以使用“with Outlook”命令在 Outlook 中设置的所有属性。
回答by Blackhawk
You can refer to this msdn pagefor descriptions of the methods and properties of the MailItem object.
您可以参考此 msdn 页面以了解 MailItem 对象的方法和属性的说明。
To make writing the code easier, you can use the Object Browser as Bathsheba suggests by declaring your MailItem instance using early binding instead of late binding. To do this, add a reference to outlook in your project by clicking "Tools" ---> "References..." and checking the box next to Microsoft Outlook 14.0 Object Library
. You can then declare the MailItem by:
为了使编写代码更容易,您可以按照 Bathsheba 的建议使用对象浏览器,方法是使用早期绑定而不是后期绑定来声明您的 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
Once you have declared OutMail as above, the VBA IDE will show you the members in the Object Browser and also give you intellisense as you code.
如上所述声明 OutMail 后,VBA IDE 将向您显示对象浏览器中的成员,并在您编写代码时为您提供智能感知。
回答by Dmitry Streblechenko
You can also look at various live Outlook Object Model and MAPI objects using OutlookSpy: select an item in Outlook, click the Item button on the OutlookSpy ribbon.
您还可以使用OutlookSpy查看各种实时 Outlook 对象模型和 MAPI 对象:在 Outlook 中选择一个项目,单击 OutlookSpy 功能区上的项目按钮。
回答by Bathsheba
Use the object browser, available from F2 in the VBA development screen.
使用对象浏览器,可从 VBA 开发屏幕中的 F2 获得。