AppointmentItem.SaveAs メソッド (Outlook)

Microsoft Outlookアイテムを、指定したパスに、指定したファイルの種類の形式で保存します。 ファイルの種類を指定しない場合は、MSG 形式 (.msg) が使用されます。

構文

SaveAs (パス)

AppointmentItem オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
パス 必須 String アイテムを保存するパスを指定します。
Type 省略可能 バリアント型 (Variant) 保存するファイルの種類です。 olHTMLolMSGolRTFolTemplate、olDocolTXTolVCal、olVCardolICalolMSGUnicode のいずれかの OlSaveAsType 定数を指定できます。

注釈

ことに注意して olDoc は、有効な OlSaveAsType 定数、文書の形式に HTML 形式のメッセージを保存することはできませんし、 olDoc 定数を有効にする既定の電子メール エディターとして Microsoft Word が設定されます。

この Visual Basic for Applications (VBA) の例では、ファイルの名前と件名を使用して、[ドキュメント] フォルダー内のテキスト ファイルとして、現在開いているアイテムを保存するのに SaveAs メソッドを使用します。 次の使用例を実行するには、プレーン テキスト形式のメール アイテムを作業中のウィンドウで開いていることを確認します。

Sub SaveAsTXT() 
 Dim myItem As Outlook.Inspector 
 Dim objItem As Object 
 
 Set myItem = Application.ActiveInspector 
 If Not TypeName(myItem) = "Nothing" Then 
 Set objItem = myItem.CurrentItem 
 strname = objItem.Subject 
 'Prompt the user for confirmation 
 Dim strPrompt As String 
 strPrompt = "Are you sure you want to save the first attachment " & _ 
 "in the current item to the Documents folder? If a file with the " & _ 
 "same name already exists in the destination folder, " & _ 
 "it will be overwritten with this copy of the file." 
 If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then 
 objItem.SaveAs Environ("HOMEPATH") & "\My Documents\" & strname & ".txt", olTXT 
 End If 
 Else 
 MsgBox "There is no current active inspector." 
 End If 
End Sub

この Visual Basic for Applications の例では、 SaveAs メソッドを使用してテンプレートを作成する方法を示します。

Sub CreateTemplate() 
 Dim MyItem As Outlook.AppointmentItem 
 
 Set MyItem = Application.CreateItem(olAppointmentItem) 
 MyItem.Subject = "Status Report" 
 MyItem.Display 
 MyItem.SaveAs Environ("HOMEPATH") & "\My Documents\statusrep.oft", OlSaveAsType.olTemplate 
End Sub

関連項目

AppointmentItem オブジェクト

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。