View Single Post
 
Old 05-30-2022, 06:25 AM
JamesMWood JamesMWood is offline Windows 10 Office 2021
Novice
 
Join Date: May 2022
Posts: 25
JamesMWood is on a distinguished road
Default

Nevermind, I got it to work. For anyone curious:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

'Strings for enclosures
Dim filename As String
filename = "c:\temp\test.pdf"

'Add enclosures to draft email
Dim aMail As Outlook.MailItem
Dim outapp As New Outlook.Application()
Dim oInspector As Outlook.Inspector
oInspector = outapp.ActiveInspector

'Determine if in line response or pop-out email reply
If oInspector Is Nothing Then
aMail = outapp.ActiveExplorer.ActiveInlineResponse
Else
aMail = oInspector.CurrentItem
End If

'Attach files
With aMail
aMail.Attachments.Add(filename,
Outlook.OlAttachmentType.olByValue, 1)
CType(aMail, Outlook._MailItem).Save()
End With

Hide() 'Hides form window after clicking attach button

End Sub
Reply With Quote