Stephen Byrom
asked on
MS Access and emailzzzzzzzz
Hi,
I've been trying for a couple of days now (on and off) to get this great code from Ron de Bruin to work, but it just won't attach the PDF file which is stored in "MY Documents" to the email. The email program (Outlook 2013) pops open, and it attaches my Signature, (later to be one from work) but I just can't get it to attach the PDF file.
Code is attached
All help is greatly appreciated.
I've been trying for a couple of days now (on and off) to get this great code from Ron de Bruin to work, but it just won't attach the PDF file which is stored in "MY Documents" to the email. The email program (Outlook 2013) pops open, and it attaches my Signature, (later to be one from work) but I just can't get it to attach the PDF file.
Code is attached
All help is greatly appreciated.
Option Compare Database
Option Explicit
Sub EmailBookings()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Dim Bkinglist As String
Bkinglist = Environ("USERPROFILE") & "\My Documents\test.pdf"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<B>Hi,</B><br>" & _
"Please review the attached PDF booking list.<br>" & _
"Let me know if you have any queries.<br>" & _
"<br><br><B>Thank you</B>"
SigString = Environ("appdata") & _
"\Microsoft\Signatures\Personal.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = "steve@joyceandstevieb.com"
.CC = ""
.BCC = ""
.Subject = "Booking List"
.HTMLBody = strbody & "<br>" & Signature
.Attachments.Add Bkinglist
.Display
' .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simple as that!!
I've been scratching my head for the past two days because of two letters!
I'm running Win7 so it's just "Documents" and not "MY" ..
Old habits die hard eh?
Thanks so much for your time