7

この一見単純なタスクを高低で検索しましたが、遭遇するすべての参照は、ハード ドライブに保存するか、Outlook フォルダーから読み取るかのいずれかです。

ハードドライブのフォルダー内のファイル名をループする次のコードがありますが、そのパスを取得して Outlook で開く方法がわかりません。

Dim inPath as String
Dim thisFile as String
Dim msg as MailItem
Dim OlApp as Object
Set OlApp = CreateObject("Outlook.Application")
inPath = "C:\temp"

thisFile = Dir(inPath & "\*.msg")
Do While thisFile <> ""
    'At this point, thisFile contains the path of a .msg like "C:\temp\mail_item1.msg"
    'msg = <open mailitem> <~~~~ HELP HERE
    'Do stuff with msg

    thisFile = Dir
Loop

この質問は似ているように見えましたが、C# 向けだったので、問題に関連する vba の同等物を取得するのに苦労しました。おそらく、Outlook vba に詳しい人には明らかでしょう。

4

1 に答える 1

9

ここを参照してください http://msdn.microsoft.com/en-us/library/office/ff865637.aspx

Sub CreateFromTemplate() 
 Dim MyItem As Outlook.MailItem 
 Set MyItem = Application.CreateItemFromTemplate("C:\statusrep.oft") 
 MyItem.Display 
End Sub 

.oft ファイルだけでなく

Set MyItem = Application.CreateItemFromTemplate("C:\temp\mail_item1.msg")

編集 - OpenSharedItem のことを忘れがちです。 http://msdn.microsoft.com/en-us/library/office/bb208171(v=office.12).aspx

于 2013-10-17T12:33:03.393 に答える