通过未绑定文本框为Outlook.MailItem添加附件时触发Error 438
邮件附件路径从文本框取值时触发Error 438问题
我能发送带附件的邮件,但只有附件路径硬编码时才正常运行,代码如下:
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
我的表单上有个名为LinkedFile1的未绑定文本框,赋值代码是:
Me.LinkedFile1 = "C:\\Users\\pat.lewis\\Desktop\\description.docx"
但当我把Me.LinkedFile1的值传给.Attachments.Add时,代码无法运行:
With olMail .To = Me.EmailTo .CC = Me.EmailCC .Subject = Me.EmailSubject .BodyFormat = olFormatPlain .Body = Me.EmailMessage .Attachments.Add Me.LinkedFile1 '无法运行!! .Send End With
该行代码会触发如下错误:
error 438: Object doesn't support this property or method
.Attachments.Add Me.LinkedFile1
就算把Me.LinkedFile1的值赋给字符串变量再引用,还是不行:
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 '还是无法运行!! .Send End With
内容的提问来源于stack exchange,提问作者Pattrick Lewis
相关产品推荐
相关产品推荐

