SendObject
レポートを電子メールの添付ファイルとしてエクスポートする方法を使用しているAccessデータベースがあります。
私ができる必要があるのは、添付ファイルを開き、テキストを(フォーマットを使用して)コピーし、生成された電子メールの本文に貼り付けて、ファイルを削除することです。
添付ファイルを削除して開くコードはありますが、Word文書のすべてをコピーして、元の電子メールに貼り付ける方法がわかりません。
どんな助けでも大歓迎です!もっと簡単な方法があれば教えてください。
Sub olAttachmentStrip()
Dim strFilename As String
Dim strPath As String
Dim olItem As Outlook.MailItem
Dim olAtmt As Outlook.Attachments
Dim olInspector As Outlook.Inspector
Dim appWord As Word.Application
Dim docWord As Word.Document
strPath = "C:\temp\"
Set olInspector = Application.ActiveInspector
If Not TypeName(olInspector) = "Nothing" Then
If TypeName(olInspector.CurrentItem) = "MailItem" Then
Set olItem = olInspector.CurrentItem
Set olAtmt = olItem.Attachments
olAtmt.Item(1).SaveAsFile strPath & olAtmt.Item(1).DisplayName
strFilename = strPath & olAtmt.Item(1).DisplayName
'olAtmt.Item(1).Delete
Else
MsgBox "Something went horribly wrong."
End If
End If
Set appWord = CreateObject("Word.Application")
appWord.Visible = False
Set docWord = appWord.Documents.Open(strFilename)
Stop '<== This is where I'm stuck!
Set docWord = Nothing
Set appWord = Nothing
End Sub