|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 sonewboy 于 2013-3-8 13:55 编辑
outlook2010, 将所有邮件archive了一下,
保存为C:\Users\xxxxxxx\Documents\Outlook Files 下的"archive.pst",
在outlook里打开了这个pst,
vba里怎样打开archive中inbox里的标题为"ABC"的邮件?
以下代码怎么修改才可以?
sub open_mail_from_archive()
Dim myOlApp As Object
Dim myNameSpace As Object
Dim myFolder As Object
Dim myItem As Object
Dim i, zr
Dim found_flag
On Error Resume Next
Set myOlApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set myOlApp = CreateObject("Outlook.application")
End If
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
For i = 1 To myFolder.Items.Count
With myFolder.Items(i)
If .Subject = "ABC" then
.Display
found_flag = True
Exit For
End If '---
End With
Next
end sub
|
|