通过代码在Outlook中发送/接收 [英] Send/Receive in Outlook via code
问题描述
如果我使用Excel VBA创建Outlook 2010对象
If I create an Outlook 2010 object In Excel VBA using
Sub CreateOL()
On Error Resume Next
Set myOlApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set myOlApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
End Sub
是否可以强制myOLAPP
发送/接收.请有人提出建议吗?
Is it possible to force myOLAPP
to send/receive. Please can somebody advise how it's done?
我已经尝试了以下方法,但对我来说不起作用.
I've tried the following but it's not working for me.
Set nsp = myOlApp.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
syc.Start
Next
此外,如何使myOlApp可见? myOlApp.Visible = True
和myOlApp.Application.Visible = True
不起作用
Also, how do I make myOlApp visible? myOlApp.Visible = True
and myOlApp.Application.Visible = True
doesn't work
谢谢
推荐答案
您使用的是哪个Outlook版本?我使用Outlook 2010对此进行了测试,并且可以正常工作.
Which Outlook version are you using? I tested this with Outlook 2010 and it works.
注意:我尚未执行任何错误处理.我相信您可以解决这个问题.
NOTE: I have not done any error handling. I am sure you can take care of that.
Public Sub Sample()
Dim oLook As Object
Dim nsp As Object, objSyncs As Object, objSync As Object
Dim i As Long
Set oLook = GetObject(, "Outlook.Application")
Set nsp = oLook.GetNamespace("MAPI")
Set objSyncs = nsp.SyncObjects
For i = 1 To objSyncs.Count
Set objSync = objSyncs.Item(i)
objSync.Start
Next
End Sub
MS Outlook具有2种类型的窗口
MS Outlook has 2 types of windows
- 文件夹和资源管理器
- 单个项目的检查器.
如果要显示特定的文件夹,则可以为其启动资源管理器,然后使用.Activate
或.Display.
.另一种方法是也使用MAPIFolder.Display
方法.
If you want to show a particular folder, you can start the Explorer for it then either use .Activate
or .Display.
An alternative would be to use MAPIFolder.Display
method as well.
这篇关于通过代码在Outlook中发送/接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!