Hi there.
I am attempting to use the following code to attach a .pdf file to an email:-
#######################################
Dim strTo As String
Dim strSubject As String
Dim strBody As String
Dim strPathAttach As String
Dim objOutlook As Object
Dim objMailItem As Object
Const olMailItem As Integer = 0
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(olMailItem)
strTo = Forms!f2_Advised!Text43
objMailItem.To = strTo
strSubject = Forms!f2_members_details!Full_name & " - Charitable status statement"
objMailItem.subject = strSubject
strBody = Forms!f2_email_text!Email_Body_Text
objMailItem.body = strBody
strPathAttach = Forms!f2_Advised!Text29 '= "R:\charity\Statements\Parker David Fi-31Aug12_email.pdf" '
With objMailItem.Attachments
.Add strPathAttach
End With
objMailItem.Send
##############################################
I am able to send out the email ... but .... the attachment will not attach
I get the error
"Cannot find the file"
"Verify the path and filename are correct"
This happens on the .Add strPathAttach line of code.
If I cut and paste the file name (as shown in the comments) into my Windows File Explorer, it loads Adobe and displays the file perfectly.
In desperation I have tried all sorts of permutations of enclosing qoutes , putting in equals signs ... adding commas ... pure desperation! ... all to no avail.
Can anyone point me to the cause of this aberration please?