I can send email with attachments, if the path of the attachment is hard-coded.
With olMail
.To = Me.EmailTo
.CC = Me.EmailCC
.Subject = Me.EmailSubject
.BodyFormat = olFormatPlain
.Body = Me.EmailMessage
.Attachments.Add "C:\Users\pat.lewis\Desktop\description.docx"
.Send
End With
On my form is an unbound textbox called LinkedFile1
.
Me.LinkedFile1 = "C:\\Users\\pat.lewis\\Desktop\\description.docx"
If I assign the value of Me.LinkedFile1
to the .Attachments.Add
property:
With olMail
.To = Me.EmailTo
.CC = Me.EmailCC
.Subject = Me.EmailSubject
.BodyFormat = olFormatPlain
.Body = Me.EmailMessage
.Attachments.Add Me.LinkedFile1 'DOESN'T WORK!!
.Send
End With
I get
error 438: Object doesn't support this property or method
at this line:
.Attachments.Add Me.LinkedFile1
It also does not work if I assign the value of Me.LinkedFile1
to a string variable then reference that:
Dim olAttachment1 As String
If IsNull(Me.AttachedFile1) = False Then
olAttachment1 = Me.LinkedFile1
End If
With olMail
.To = Me.EmailTo
.CC = Me.EmailCC
.Subject = Me.EmailSubject
.BodyFormat = olFormatPlain
.Body = Me.EmailMessage
.Attachments.Add olAttachment1 'DOESN'T WORK EITHER!!
.Send
End With
Using UNBOUND textbox set with result of FilePicker works just fine for me.
Only issue with textbox I can think of that would cause this failure is corruption. If running Decompile/Compile and/or Compact & Repair and/or deleting & replacing textbox does not resolve, eliminate it from the process. Set olAttachment1 variable directly with result of FilePicker. You can still set the textbox if you want to display to user.