Good day,
I am trying to browse for the attachment when sending an email to a client - I have the email code working okay, I have come up with this...and it's not working, like I would like it to.
many thanks
I am trying to browse for the attachment when sending an email to a client - I have the email code working okay, I have come up with this...and it's not working, like I would like it to.
many thanks
Code:
Private Sub CommandButton1_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim qfile As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "test@gmail.com"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hello World!"
.attachments.Add = qfile
filepath = Application.GetOpenFilename("PDF Files (*.pdf), *.pdf")
If filepath <> False Then
qfile = filepath
End If
.display
'.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub